Class: Octorule::Services::BranchProtection
- Inherits:
-
Object
- Object
- Octorule::Services::BranchProtection
- Defined in:
- lib/octorule/services/branch_protection.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ BranchProtection
constructor
A new instance of BranchProtection.
- #update(org, repo, branch, settings, dry_run: false) ⇒ Object
Constructor Details
#initialize(client) ⇒ BranchProtection
Returns a new instance of BranchProtection.
6 7 8 |
# File 'lib/octorule/services/branch_protection.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#update(org, repo, branch, settings, dry_run: false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/octorule/services/branch_protection.rb', line 10 def update(org, repo, branch, settings, dry_run: false) if dry_run puts "Would update branch protection for #{branch} in #{repo}:" settings.each { |k, v| puts " #{k}: #{v}" } else @client.protect_branch("#{org}/#{repo}", branch, settings) puts "Successfully updated branch protection for #{branch} in #{repo}" end rescue Octokit::Error => e warn "Failed to update branch protection for #{branch} in #{repo}: #{e.}" end |