Class: CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist

Inherits:
CreateGithubRelease::AssertionBase show all
Defined in:
lib/create_github_release/assertions/local_release_branch_does_not_exist.rb

Overview

Assert that the release branch does not exist in the local repository

Instance Attribute Summary

Attributes inherited from CreateGithubRelease::AssertionBase

#project

Instance Method Summary collapse

Methods inherited from CreateGithubRelease::AssertionBase

#backtick_debug?, #error, #initialize, #print, #puts

Methods included from BacktickDebug

#`

Constructor Details

This class inherits a constructor from CreateGithubRelease::AssertionBase

Instance Method Details

#assert

This method returns an undefined value.

Assert that the release branch does not exist in the local repository

Examples:

require 'create_github_release'

options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
project = CreateGithubRelease::Project.new(options)
assertion = CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist.new(project)
begin
  assertion.assert
  puts 'Assertion passed'
rescue SystemExit
  puts 'Assertion failed'
end

Raises:

  • (SystemExit)

    if the assertion fails



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/create_github_release/assertions/local_release_branch_does_not_exist.rb', line 32

def assert
  print "Checking that local branch ' #{project.release_branch}' does not exist..."

  branches = `git branch --list "#{project.release_branch}"`.chomp
  error 'Could not list branches' unless $CHILD_STATUS.success?

  if branches == ''
    puts 'OK'
  else
    error "Local branch '#{project.release_branch}' already exists"
  end
end