Class: MultiRepo::Helpers::UpdateBranchProtection

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_repo/helpers/update_branch_protection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_name, branch:, dry_run: false) ⇒ UpdateBranchProtection

Returns a new instance of UpdateBranchProtection.



5
6
7
8
9
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 5

def initialize(repo_name, branch:, dry_run: false, **)
  @repo_name = repo_name
  @branch    = branch
  @github    = MultiRepo::Service::Github.new(dry_run: dry_run)
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



3
4
5
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 3

def branch
  @branch
end

#dry_runObject (readonly)

Returns the value of attribute dry_run.



3
4
5
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 3

def dry_run
  @dry_run
end

#githubObject (readonly)

Returns the value of attribute github.



3
4
5
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 3

def github
  @github
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



3
4
5
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 3

def repo_name
  @repo_name
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/multi_repo/helpers/update_branch_protection.rb', line 11

def run
  puts "Protecting #{branch} branch"

  settings = {
    :enforce_admins                => nil,
    :required_status_checks        => nil,
    :required_pull_request_reviews => nil,
    :restrictions                  => nil
  }

  github.protect_branch(repo_name, branch, settings)
end