Class: MultiRepo::Helpers::RenameLabels
- Inherits:
-
Object
- Object
- MultiRepo::Helpers::RenameLabels
- Defined in:
- lib/multi_repo/helpers/rename_labels.rb
Instance Attribute Summary collapse
-
#github ⇒ Object
readonly
Returns the value of attribute github.
-
#rename_hash ⇒ Object
readonly
Returns the value of attribute rename_hash.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
Instance Method Summary collapse
-
#initialize(repo_name, rename_hash, dry_run: false) ⇒ RenameLabels
constructor
A new instance of RenameLabels.
- #run ⇒ Object
Constructor Details
#initialize(repo_name, rename_hash, dry_run: false) ⇒ RenameLabels
Returns a new instance of RenameLabels.
5 6 7 8 9 |
# File 'lib/multi_repo/helpers/rename_labels.rb', line 5 def initialize(repo_name, rename_hash, dry_run: false, **) @repo_name = repo_name @rename_hash = rename_hash @github = MultiRepo::Service::Github.new(dry_run: dry_run) end |
Instance Attribute Details
#github ⇒ Object (readonly)
Returns the value of attribute github.
3 4 5 |
# File 'lib/multi_repo/helpers/rename_labels.rb', line 3 def github @github end |
#rename_hash ⇒ Object (readonly)
Returns the value of attribute rename_hash.
3 4 5 |
# File 'lib/multi_repo/helpers/rename_labels.rb', line 3 def rename_hash @rename_hash end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
3 4 5 |
# File 'lib/multi_repo/helpers/rename_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 |
# File 'lib/multi_repo/helpers/rename_labels.rb', line 11 def run rename_hash.each do |old_name, new_name| github_label = existing_labels.detect { |l| l.name == old_name } if github_label puts "Renaming label #{old_name.inspect} to #{new_name.inspect}" github.update_label(repo_name, old_name, name: new_name) end end end |