Commit 99ba0bc7 authored by Rémy Coutable's avatar Rémy Coutable

Allow files to belong to multiple categories in the roulette

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 91895122
...@@ -73,16 +73,16 @@ module Gitlab ...@@ -73,16 +73,16 @@ module Gitlab
# @return [Hash<String,Array<String>>] # @return [Hash<String,Array<String>>]
def changes_by_category def changes_by_category
all_changed_files.each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash| all_changed_files.each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash|
hash[category_for_file(file)] << file categories_for_file(file).each { |category| hash[category] << file }
end end
end end
# Determines the category a file is in, e.g., `:frontend` or `:backend` # Determines the categories a file is in, e.g., `[:frontend]`, `[:backend]`, or `%i[frontend engineering_productivity]`.
# @return[Symbol] # @return Array<Symbol>
def category_for_file(file) def categories_for_file(file)
_, category = CATEGORIES.find { |regexp, _| regexp.match?(file) } _, categories = CATEGORIES.find { |regexp, _| regexp.match?(file) }
category || :unknown Array(categories || :unknown)
end end
# Returns the GFM for a category label, making its best guess if it's not # Returns the GFM for a category label, making its best guess if it's not
...@@ -125,10 +125,13 @@ module Gitlab ...@@ -125,10 +125,13 @@ module Gitlab
jest\.config\.js | jest\.config\.js |
package\.json | package\.json |
yarn\.lock | yarn\.lock |
config/.+\.js | config/.+\.js
\.gitlab/ci/frontend\.gitlab-ci\.yml
)\z}x => :frontend, )\z}x => :frontend,
%r{(\A|/)(
\.gitlab/ci/frontend\.gitlab-ci\.yml
)\z}x => %i[frontend engineering_productivity],
%r{\A(ee/)?db/(?!fixtures)[^/]+} => :database, %r{\A(ee/)?db/(?!fixtures)[^/]+} => :database,
%r{\A(ee/)?lib/gitlab/(database|background_migration|sql|github_import)(/|\.rb)} => :database, %r{\A(ee/)?lib/gitlab/(database|background_migration|sql|github_import)(/|\.rb)} => :database,
%r{\A(app/models/project_authorization|app/services/users/refresh_authorized_projects_service)(/|\.rb)} => :database, %r{\A(app/models/project_authorization|app/services/users/refresh_authorized_projects_service)(/|\.rb)} => :database,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment