Class: RGitFlow::Tasks::SCM::Tag
- 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
- #dirty? ⇒ Boolean protected
-
#initialize(git) ⇒ Tag
constructor
A new instance of Tag.
- #print_status ⇒ Object protected
- #run ⇒ Object protected
Methods inherited from Task
Methods included from Console
Methods included from Printing
#debug, #error, #prompt, #status
Constructor Details
#initialize(git) ⇒ Tag
7 8 9 10 |
# File 'lib/rgitflow/tasks/scm/tag.rb', line 7 def initialize(git) super(git, 'tag', 'Tags the repository', ['rgitflow', 'scm']) end |
Instance Method Details
#dirty? ⇒ Boolean (protected)
38 39 40 |
# File 'lib/rgitflow/tasks/scm/tag.rb', line 38 def dirty? @git.diff.size > 0 end |
#print_status ⇒ Object (protected)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rgitflow/tasks/scm/tag.rb', line 42 def print_status added = [] modified = [] deleted = [] @git.diff.each { |f| if f.type == 'new' added << f elsif f.type == 'modified' modified << f elsif f.type == 'deleted' deleted << f end } debug 'added' msg = %Q(#{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT} #{f.path}#{ANSI::Constants::CLEAR}) added.each { |f| debug " #{msg}" } debug 'modified' msg = %Q(#{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT} #{f.path}#{ANSI::Constants::CLEAR}) modified.each { |f| debug " #{msg}" } debug 'deleted' msg = %Q(#{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT} #{f.path}#{ANSI::Constants::CLEAR}) deleted.each { |f| debug " #{msg}" } end |
#run ⇒ Object (protected)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rgitflow/tasks/scm/tag.rb', line 14 def run status 'Creating tag...' if dirty? error 'There are uncommitted changes in the repository!' print_status abort else status 'There are no uncommitted changes in the repository.' end tag = ENV['TAG'] || ("#{RGitFlow::Config.options[:tag]}" % RGitFlow::VERSION.to_s) unless @git..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 |