//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
println("Hello world! - groovy.jsrun.net")
// def line = '["name":"dev","commit":{"id":"136056fde81bed2512d6d36a74657fb1894e1d8f","short_id":"136056fd","created_at":"2022-11-12T22:39:11.000+08:00","parent_ids":["a4f62ea379b21e91f7308dc61a3bbfcee9632cac"],"title":"route: merge _SADP_FILLS_RESERVED net metals with OBS","message":"route: merge _SADP_FILLS_RESERVED net metals with OBS\n","author_name":"wangwenjie","author_email":"wangwj@niiceda.com","authored_date":"2022-11-10T14:30:22.000+08:00","committer_name":"devops","committer_email":"devops@niiceda.com","committed_date":"2022-11-12T22:39:11.000+08:00","web_url":"http://gitlab.srv/niiceda/nice_release/-/commit/136056fde81bed2512d6d36a74657fb1894e1d8f"},"merged":false,"protected":true,"developers_can_push":false,"developers_can_merge":false,"can_push":false,"default":true,"web_url":"http://gitlab.srv/niiceda/nice_release/-/tree/dev"]'
// def m = line.replace('{','[').replace('}',']') .replace('\n', '')
// def map = evaluate(m)
// def short_id =(map['commit']['short_id'])
// def time =(map['commit']['created_at'])
// println(time)
// // def m_ = time =~ /(.*?)[A-Za-z]/
// // //assert m[0][1] == "bar"
// // println(m_[0][1].replace("-",""))
// def time_d = time =~ /[A-Za-z](.*)\./
// println(time_d[0][1].replace(":","")[0..3])
// def commit = "latest"
// if ("${commit}" == 'latest'){
// println('test')
// }
// def line1 = '[{"id":4952,"iid":2032,"project_id":73,"title":"route: Support Trim-related keywords in EnclosureTable(Part2). #665","description":"Code changes: 1. Use DrcChecker interfaces to query trimMetal. 2. Fix minor bugs.\nRegression changes: No regression fail.","state":"merged","created_at":"2022-12-09T15:54:21.769+08:00","updated_at":"2022-12-09T16:56:09.655+08:00","merged_by":{"id":109,"name":"CI-Bot","username":"ci-bot","state":"active","avatar_url":"http://gitlab.srv/uploads/-/system/user/avatar/109/avatar.png","web_url":"http://gitlab.srv/ci-bot"},"merged_at":"2022-12-09T16:56:09.718+08:00","closed_by":null,"closed_at":null,"target_branch":"dev","source_branch":"dev-huangxj-pr-1","user_notes_count":8,"upvotes":0,"downvotes":0,"author":{"id":13,"name":"Huangxinjie","username":"huangxj","state":"active","avatar_url":null,"web_url":"http://gitlab.srv/huangxj"},"assignees":[{"id":12,"name":"yangxiaohu","username":"yangxiaohu","state":"active","avatar_url":null,"web_url":"http://gitlab.srv/yangxiaohu"}],"assignee":{"id":12,"name":"yangxiaohu","username":"yangxiaohu","state":"active","avatar_url":null,"web_url":"http://gitlab.srv/yangxiaohu"},"source_project_id":89,"target_project_id":73,"labels":["approved","merge-test-pass","self-test-pass"],"work_in_progress":false,"milestone":null,"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"26f71a08e680ab38a2ded80ac8fad85c5e6ecb5e","merge_commit_sha":null,"squash_commit_sha":null,"discussion_locked":null,"should_remove_source_branch":null,"force_remove_source_branch":false,"allow_collaboration":false,"allow_maintainer_to_push":false,"reference":"!2032","references":{"short":"!2032","relative":"!2032","full":"niiceda/nice!2032"},"web_url":"http://gitlab.srv/niiceda/nice/-/merge_requests/2032","time_stats":{"time_estimate":0,"total_time_spent":0,"human_time_estimate":null,"human_total_time_spent":null},"squash":false,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true}]'
// def line = line1[1..-2].replace('{','[').replace('}',']') .replace('\n', '')
// def map = evaluate(line)
// //print(map)
// def time =(map['updated_at'])
// def branch =(map['target_branch'])
// println(time)
// println(branch)
// def branch_test = 'dev1'
// assert(branch == branch_test)
// def m_ = time =~ /(.*?)[A-Za-z]/
// //assert m[0][1] == "bar"
// println(m_[0][1].replace("-",""))
// def time_d = time =~ /[A-Za-z](.*)\./
// println(time_d[0][1].replace(":","")[0..3])
def line = '[{"id":246,"description":"","name":"nice","name_with_namespace":"songzeren / nice","path":"nice","path_with_namespace":"songzr/nice","created_at":"2022-12-09T09:27:46.316+08:00","default_branch":"dev","tag_list":[],"ssh_url_to_repo":"ssh://git@gitlab.srv:7022/songzr/nice.git","http_url_to_repo":"http://gitlab.srv/songzr/nice.git","web_url":"http://gitlab.srv/songzr/nice","readme_url":"http://gitlab.srv/songzr/nice/-/blob/dev/README.md","avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2022-12-09T09:27:46.316+08:00","namespace":{"id":162,"name":"songzeren","path":"songzr","kind":"user","full_path":"songzr","parent_id":null,"avatar_url":null,"web_url":"http://gitlab.srv/songzr"},"_links":{"self":"http://gitlab.srv/api/v4/projects/246","issues":"http://gitlab.srv/api/v4/projects/246/issues","merge_requests":"http://gitlab.srv/api/v4/projects/246/merge_requests","repo_branches":"http://gitlab.srv/api/v4/projects/246/repository/branches","labels":"http://gitlab.srv/api/v4/projects/246/labels","events":"http://gitlab.srv/api/v4/projects/246/events","members":"http://gitlab.srv/api/v4/projects/246/members"},"packages_enabled":true,"empty_repo":false,"archived":false,"visibility":"internal","owner":{"id":135,"name":"songzeren","username":"songzr","state":"active","avatar_url":null,"web_url":"http://gitlab.srv/songzr"},"resolve_outdated_diff_discussions":false,"container_registry_enabled":true,"container_expiration_policy":{"cadence":"1d","enabled":true,"keep_n":10,"older_than":"90d","name_regex":null,"name_regex_keep":null,"next_run_at":"2022-12-11T09:50:05.705+08:00"},"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":false,"snippets_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"disabled","snippets_access_level":"enabled","pages_access_level":"private","emails_disabled":false,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":135,"forked_from_project":{"id":73,"description":"","name":"nice","name_with_namespace":"NiiCEDA / nice"}]'
def repo_url = 'http://gitlab.srv/NiiCEDA/nice.git'
def namespace_name = repo_url =~ /gitlab.srv\/(.*)\./
println(namespace_name[0][1])
def namespace = namespace_name[0][1].split('/')[0]
def name = namespace_name[0][1].split('/')[1]
println(namespace)
println(name)
info = "\"name\":\"" + "${name}" + "\",\"name_with_namespace\":\"" + "${namespace}" + " / " + "${name}" + "\""
//def info = "\"name"":"${name}","name_with_namespace":"${namespace} / ${name}"
// //println(info)
def pr_id_info = str =~ /(.*?)${info}/
// def pr_id_info_match = pr_id_info[0][1]
// //search method need to enhance, too excess steps!!!
// def pr_id_last = pr_id_info_match.split('id')[-1]
// def id = pr_id_last =~ /\:(.*?)\,/
// def pr_id = id[0][1]
//def pr_id = line =~ /(id":)(^\d+$).*${info}/
//println(lit)
// def pr_id = line =~ /[^\d+$].*${info}/
// //def pr_id_ = pr_id[0][1].split('{')[-1]
// println(pr_id[0][7])