diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-26 18:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-26 18:08:29 +0300 |
commit | cac0926ddbef9d1505c2a23ccad60fd47c7d050a (patch) | |
tree | ef6808933314a104d004528f7c84716dc472d93a /tooling | |
parent | afd476d5fd62d31c7e0b7509691fa18e632a60df (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rw-r--r-- | tooling/config/CODEOWNERS.yml | 91 | ||||
-rw-r--r-- | tooling/lib/tooling/find_codeowners.rb | 32 |
2 files changed, 74 insertions, 49 deletions
diff --git a/tooling/config/CODEOWNERS.yml b/tooling/config/CODEOWNERS.yml index d867c8c22fc..4fa7338b32d 100644 --- a/tooling/config/CODEOWNERS.yml +++ b/tooling/config/CODEOWNERS.yml @@ -6,53 +6,52 @@ '@gitlab-org/manage/authentication-and-authorization': allow: keywords: - - password - - auth - - token + - 'password' + - 'auth' + - 'token' patterns: - - '/{,ee/}app/**/*%{keyword}*{/**/*,}' - - '/{,ee/}config/**/*%{keyword}*{/**/*,}' - - '/{,ee/}lib/**/*%{keyword}*{/**/*,}' + - '/{,ee/}app/**/*%{keyword}*{,/**/*}' + - '/{,ee/}config/**/*%{keyword}*{,/**/*}' + - '/{,ee/}lib/**/*%{keyword}*{,/**/*}' deny: keywords: - - author. - - author_ - - authored - - authoring - - .png - - .svg - - deploy_token - - runner{,s}_token - - job_token - - autocomplete_tokens - - dast_site_token - - reset_prometheus_token - - reset_registration_token - - runners_registration_token - - terraform_registry_token - - tokenizer - - filtered_search - - /alert_management/ - - /analytics/ - - /bitbucket/ - - /clusters/ - - /clusters_list/ - - /dast/ - - /dast_profiles/ - - /dast_site_tokens/ - - /dast_site_validation/ - - /dependency_proxy/ - - /error_tracking/ - - /google_api/ - - /google_cloud/ - - /jira_connect/ - - /kubernetes/ - - /protected_environments/ - - /config/feature_flags/development/jira_connect_ - - /config/metrics/ - - /app/controllers/groups/dependency_proxy_auth_controller.rb - - /app/finders/ci/auth_job_finder.rb - - /ee/config/metrics/ - - /lib/gitlab/conan_token.rb + - '*author.*' + - '*author_*' + - '*authored*' + - '*authoring*' + - '*.png' + - '*.svg' + - '*deploy_token{,s}{*,/**/*}' + - '*runner{,s}_token*' + - '*job_token{,_scope}{*,/**/*}' + - '*autocomplete_tokens*' + - 'dast_site_token*' + - 'reset_prometheus_token*' + - 'reset_registration_token*' + - 'runners_registration_token{*,/**/*}' + - 'terraform_registry_token*' + - 'filtered_search{_bar,}/' + - 'alert_management/' + - 'analytics/' + - 'bitbucket/' + - 'clusters/' + - 'clusters_list/' + - 'dast/' + - 'dast_profiles/' + - 'dast_site_tokens/' + - 'dast_site_validation/' + - 'dependency_proxy/' + - 'error_tracking/' + - 'google_api/' + - 'google_cloud/' + - 'jira_connect/' + - 'kubernetes/' + - 'protected_environments/' + - '/config/feature_flags/development/jira_connect_*' + - '/config/metrics/' + - '/app/controllers/groups/dependency_proxy_auth_controller.rb' + - '/app/finders/ci/auth_job_finder.rb' + - '/ee/config/metrics/' + - '/lib/gitlab/conan_token.rb' patterns: - - '**/*%{keyword}*{/**/*,}' + - '%{keyword}' diff --git a/tooling/lib/tooling/find_codeowners.rb b/tooling/lib/tooling/find_codeowners.rb index 35d8a9d7461..3b50b33d85c 100644 --- a/tooling/lib/tooling/find_codeowners.rb +++ b/tooling/lib/tooling/find_codeowners.rb @@ -31,8 +31,14 @@ module Tooling consolidated_again = consolidate_paths(consolidated) end - consolidated.each do |file| - puts "/#{file.chomp} #{group}" + consolidated.each do |line| + path = line.chomp + + if File.directory?(path) + puts "/#{path}/ #{group}" + else + puts "/#{path} #{group}" + end end end end @@ -76,7 +82,27 @@ module Tooling flags |= ::File::FNM_EXTGLOB # END extension - ::File.fnmatch?(pattern, path, flags) + ::File.fnmatch?(normalize_pattern(pattern), path, flags) + end + + # Copied from ee/lib/gitlab/code_owners/file.rb + def normalize_pattern(pattern) + # Remove `\` when escaping `\#` + pattern = pattern.sub(/\A\\#/, '#') + # Replace all whitespace preceded by a \ with a regular whitespace + pattern = pattern.gsub(/\\\s+/, ' ') + + return '/**/*' if pattern == '*' + + unless pattern.start_with?('/') + pattern = "/**/#{pattern}" + end + + if pattern.end_with?('/') + pattern = "#{pattern}**/*" + end + + pattern end def consolidate_paths(matched_files) |