Class: Neetob::CLI::Github::ProtectBranch
- Defined in:
- lib/neetob/cli/github/protect_branch.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#all_neeto_repos ⇒ Object
Returns the value of attribute all_neeto_repos.
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#branch_name ⇒ Object
Returns the value of attribute branch_name.
-
#required_rules_json_file_path ⇒ Object
Returns the value of attribute required_rules_json_file_path.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(branch_name, apps, required_rules_json_file_path = "", sandbox = false, all_neeto_repos = false) ⇒ ProtectBranch
constructor
A new instance of ProtectBranch.
- #run ⇒ Object
Methods inherited from Base
#check_for_apps_and_all_neeto_repos_option
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(branch_name, apps, required_rules_json_file_path = "", sandbox = false, all_neeto_repos = false) ⇒ ProtectBranch
Returns a new instance of ProtectBranch.
11 12 13 14 15 16 17 18 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 11 def initialize(branch_name, apps, required_rules_json_file_path = "", sandbox = false, all_neeto_repos = false) super() @branch_name = branch_name @required_rules_json_file_path = required_rules_json_file_path @apps = apps @sandbox = sandbox @all_neeto_repos = all_neeto_repos end |
Instance Attribute Details
#all_neeto_repos ⇒ Object
Returns the value of attribute all_neeto_repos.
9 10 11 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 9 def all_neeto_repos @all_neeto_repos end |
#apps ⇒ Object
Returns the value of attribute apps.
9 10 11 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 9 def apps @apps end |
#branch_name ⇒ Object
Returns the value of attribute branch_name.
9 10 11 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 9 def branch_name @branch_name end |
#required_rules_json_file_path ⇒ Object
Returns the value of attribute required_rules_json_file_path.
9 10 11 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 9 def required_rules_json_file_path @required_rules_json_file_path end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
9 10 11 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 9 def sandbox @sandbox end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/neetob/cli/github/protect_branch.rb', line 20 def run check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos) matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos) inform_about_default_rules_file matching_apps.each do |app| ui.info("\n Working on \"#{app}\" repo") ui.info(" Updating \"#{branch_name}\" branch protection rules") rules = read_json_file(required_rules_json_file_path || default_rules_file_path) rules_with_symbol_keys = rules.transform_keys(&:to_sym) client.protect_branch(app, branch_name, rules_with_symbol_keys) ui.success("Branch protection rules updated successfully") end end |