class RGitFlow::Tasks::SCM::Tag

Public Class Methods

new(git) click to toggle source
Calls superclass method RGitFlow::Tasks::SCM::Task::new
# File lib/rgitflow/tasks/scm/tag.rb, line 7
def initialize(git)
  super(git, 'tag', 'Tags the repository')
end

Protected Instance Methods

run() click to toggle source
# 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