Commit 69778de7 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '218241-allow-files-to-have-multiple-categories' into 'master'

Allow files to belong to multiple categories in the roulette

Closes #218241

See merge request gitlab-org/gitlab!35660
parents 4eef5e5f 99ba0bc7
......@@ -73,16 +73,16 @@ module Gitlab
# @return [Hash<String,Array<String>>]
def changes_by_category
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
# Determines the category a file is in, e.g., `:frontend` or `:backend`
# @return[Symbol]
def category_for_file(file)
_, category = CATEGORIES.find { |regexp, _| regexp.match?(file) }
# Determines the categories a file is in, e.g., `[:frontend]`, `[:backend]`, or `%i[frontend engineering_productivity]`.
# @return Array<Symbol>
def categories_for_file(file)
_, categories = CATEGORIES.find { |regexp, _| regexp.match?(file) }
category || :unknown
Array(categories || :unknown)
end
# Returns the GFM for a category label, making its best guess if it's not
......@@ -125,10 +125,13 @@ module Gitlab
jest\.config\.js |
package\.json |
yarn\.lock |
config/.+\.js |
\.gitlab/ci/frontend\.gitlab-ci\.yml
config/.+\.js
)\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/)?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,
......
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