Class: MultiRepo::Helpers::UpdateLabels
- Inherits:
-
Object
- Object
- MultiRepo::Helpers::UpdateLabels
- Defined in:
- lib/multi_repo/helpers/update_labels.rb
Instance Attribute Summary collapse
-
#expected_labels ⇒ Object
readonly
Returns the value of attribute expected_labels.
-
#github ⇒ Object
readonly
Returns the value of attribute github.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
Instance Method Summary collapse
-
#initialize(repo_name, dry_run: false) ⇒ UpdateLabels
constructor
A new instance of UpdateLabels.
- #run ⇒ Object
Constructor Details
#initialize(repo_name, dry_run: false) ⇒ UpdateLabels
Returns a new instance of UpdateLabels.
5 6 7 8 9 |
# File 'lib/multi_repo/helpers/update_labels.rb', line 5 def initialize(repo_name, dry_run: false, **) @repo_name = repo_name @expected_labels = MultiRepo::Labels[repo_name] @github = MultiRepo::Service::Github.new(dry_run: dry_run) end |
Instance Attribute Details
#expected_labels ⇒ Object (readonly)
Returns the value of attribute expected_labels.
3 4 5 |
# File 'lib/multi_repo/helpers/update_labels.rb', line 3 def expected_labels @expected_labels end |
#github ⇒ Object (readonly)
Returns the value of attribute github.
3 4 5 |
# File 'lib/multi_repo/helpers/update_labels.rb', line 3 def github @github end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
3 4 5 |
# File 'lib/multi_repo/helpers/update_labels.rb', line 3 def repo_name @repo_name end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/multi_repo/helpers/update_labels.rb', line 11 def run if expected_labels.nil? puts "!! No labels defined for #{repo_name}" return end expected_labels.each do |label, color| github_label = existing_labels.detect { |l| l.name == label } if !github_label puts "Creating #{label.inspect} with #{color.inspect}" github.create_label(repo_name, label, color) elsif github_label.color.downcase != color.downcase puts "Updating #{label.inspect} to #{color.inspect}" github.update_label(repo_name, label, color: color) end end end |