Class: FaHarnessTools::CheckBranchProtection
- Inherits:
-
Object
- Object
- FaHarnessTools::CheckBranchProtection
- Defined in:
- lib/fa-harness-tools/check_branch_protection.rb
Overview
Check if the sha being deployed belongs to the given branch.
Instance Method Summary collapse
-
#initialize(client:, context:, branch:) ⇒ CheckBranchProtection
constructor
A new instance of CheckBranchProtection.
- #verify? ⇒ Boolean
Constructor Details
#initialize(client:, context:, branch:) ⇒ CheckBranchProtection
Returns a new instance of CheckBranchProtection.
4 5 6 7 8 9 10 11 12 |
# File 'lib/fa-harness-tools/check_branch_protection.rb', line 4 def initialize(client:, context:, branch:) @client = client @context = context @branch = branch @logger = CheckLogger.new( name: "Check branch protection", description: "Only allow commits on the #{@branch} branch to be deployed", ) end |
Instance Method Details
#verify? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fa-harness-tools/check_branch_protection.rb', line 14 def verify? @logger.start @logger.context_info(@client, @context) new_sha = @context.new_commit_sha @logger.info("checking if #{@branch} branch contains the commit") if @client.branch_contains?(@branch, new_sha) @logger.pass "#{@branch} contains #{new_sha}" else @logger.fail "#{@branch} does not contain #{new_sha}" end end |