diff options
author | Nick Thomas <nick@gitlab.com> | 2019-02-07 12:55:23 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-02-13 16:30:02 +0000 |
commit | f034a352507f09aca1a656f2bbf88c8dd8af103b (patch) | |
tree | 76795b58872436bde6ffb8b592bbfec20f11d079 /danger/plugins | |
parent | bd17881bf592c0b8c662cc189c4e27bed8895f98 (diff) | |
download | gitlab-ce-f034a352507f09aca1a656f2bbf88c8dd8af103b.tar.gz |
Move change category detection to a helper
Diffstat (limited to 'danger/plugins')
-rw-r--r-- | danger/plugins/helper.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/danger/plugins/helper.rb b/danger/plugins/helper.rb index f4eb9119266..1a2710463ad 100644 --- a/danger/plugins/helper.rb +++ b/danger/plugins/helper.rb @@ -30,5 +30,22 @@ module Danger .to_a .sort end + + # @return [Hash<String,Array<String>>] + def changes_by_category + all_changed_files.inject(Hash.new { |h, k| h[k] = [] }) do |hsh, file| + hsh[category_for_file(file)] << file + end + end + + def category_for_file(file) + _, category = CATEGORIES.find { |regexp, _| regexp.match?(file) } + + category || :unknown + end + + CATEGORIES = { + %r{\Adoc/} => :documentation + } end end |