Class: CreateGithubRelease::Assertions::LastReleaseTagExists

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

Overview

Assert that the release tag 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 last release tag exists in the local repository

Examples:

require 'create_github_release'

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

Raises:

  • (SystemExit)

    if the assertion fails



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

def assert
  return if project.first_release?

  print "Checking that last release tag '#{project.last_release_tag}' exists..."

  tags = `git tag --list "#{project.last_release_tag}"`.chomp
  error 'Could not list tags' unless $CHILD_STATUS.success?

  if tags == ''
    error "Last release tag '#{project.last_release_tag}' does not exist"
  else
    puts 'OK'
  end
end