Skip to content

Commit

Permalink
Merge pull request #485 from bdunne/move_static_labels_to_setings
Browse files Browse the repository at this point in the history
Move unassignable and unremovable labels from constants to settings
  • Loading branch information
Fryguy authored Mar 13, 2020
2 parents fdec13a + 0444c41 commit 4325a17
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ bugzilla:
product:
grafana:
url:
labels:
unassignable: {}
unremovable: []

# Worker settings
diff_content_checker:
Expand Down
6 changes: 6 additions & 0 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
:labels:
:unassignable:
jansa/yes: jansa/yes?
:unremovable:
- jansa/no
- jansa/yes
# In test, turn everything on by default
# NOTE: Using empty string is a HACK until we can get
# https://github.com/danielsdeleo/deep_merge/pull/33 released via the
Expand Down
8 changes: 4 additions & 4 deletions lib/github_service/commands/add_label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module Commands
class AddLabel < Base
include IsTeamMember

UNASSIGNABLE = {
"jansa/yes" => "jansa/yes?"
}.freeze
def unassignable_labels
@unassignable_labels ||= Settings.labels.unassignable.to_h.stringify_keys
end

private

Expand Down Expand Up @@ -57,7 +57,7 @@ def correct_invalid_labels(valid_labels, invalid_labels)

def handle_unassignable_labels(valid_labels)
valid_labels.map! do |label|
UNASSIGNABLE.key?(label) ? UNASSIGNABLE[label] : label
unassignable_labels.key?(label) ? unassignable_labels[label] : label
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/github_service/commands/remove_label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module Commands
class RemoveLabel < Base
include IsTeamMember

UNREMOVABLE = %w[jansa/yes jansa/no].freeze

alias_as 'rm_label'

private
Expand Down Expand Up @@ -40,7 +38,7 @@ def extract_label_names(value)

def process_extracted_labels(issuer, valid_labels, _invalid_labels, unremovable)
unless triage_member?(issuer)
valid_labels.each { |label| unremovable << label if UNREMOVABLE.include?(label) }
valid_labels.each { |label| unremovable << label if Settings.labels.unremovable.include?(label) }
unremovable.each { |label| valid_labels.delete(label) }
end
end
Expand Down

0 comments on commit 4325a17

Please sign in to comment.