Class: RGitFlow::Tasks::SCM::Tag

Inherits:
Task show all
Defined in:
lib/rgitflow/tasks/scm/tag.rb

Constant Summary

Constants included from Printing

Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::INPUT_PREFIX, Printing::STATUS_PREFIX

Instance Attribute Summary

Attributes inherited from Task

#after, #before, #dependencies, #description, #name, #namespaces

Instance Method Summary collapse

Methods inherited from Task

#dirty?, #print_status

Methods inherited from Task

#define

Methods included from Console

#execute, #invoke, #multi_task, #task?

Methods included from Printing

#debug, #error, #prompt, #status

Constructor Details

#initialize(git) ⇒ Tag

Returns a new instance of Tag.



7
8
9
# File 'lib/rgitflow/tasks/scm/tag.rb', line 7

def initialize(git)
  super(git, 'tag', 'Tags the repository')
end

Instance Method Details

#runObject (protected)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rgitflow/tasks/scm/tag.rb', line 13

def run
  status 'Creating tag...'
  if dirty?
    error 'There are uncommitted changes in the repository!'

    print_status

    abort
  end
  status 'There are no uncommitted changes in the repository.'
  tag = ENV['TAG'] || ("#{RGitFlow::Config.options[:tag]}" %
      RGitFlow::VERSION.to_s)
  unless @git.tags.select { |t| t.name == tag }.length == 0
    error 'Cannot create a tag that already exists!'
    abort
  end
  @git.add_tag tag, { :m => "tagging as #{tag}" }

  @git.push 'origin', @git.current_branch, { :tags => true }

  status 'Successfully created tag!'
end