Class: Emeril::GitTagger

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/emeril/git_tagger.rb

Overview

Applies a version tag on a git repository and pushes it to the origin remote.

Author:

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ GitTagger

Creates a new instance.

Parameters:

  • options (Hash) (defaults to: {})

    configuration for a git tagger

Options Hash (options):

  • an (Logger)

    optional logger instance

  • source_path (String)

    the path to a git repository

  • tag_prefix (String)

    a prefix for a git tag version string

  • version (String) — default: required

    a version string

Raises:

  • (ArgumentError)

    if any required options are not set



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/emeril/git_tagger.rb', line 35

def initialize(options = {})
  @logger = options[:logger]
  @source_path = options.fetch(:source_path, Dir.pwd)
  @tag_prefix = case options[:tag_prefix]
  when nil then
    DEFAULT_TAG_PREFIX
  when false
    ""
  else
    options[:tag_prefix]
  end
  @version = options.fetch(:version) do
    raise ArgumentError, ":version must be set"
  end
end

Instance Method Details

#runObject

Applies a version tag on a git repository and pushes it to the origin remote.



54
55
56
57
# File 'lib/emeril/git_tagger.rb', line 54

def run
  guard_clean
  tag_version { git_push } unless already_tagged?
end