Class: RGitFlow::Tasks::SCM::Status
- Defined in:
- lib/rgitflow/tasks/scm/status.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) ⇒ Status
constructor
A new instance of Status.
- #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) ⇒ Status
Returns a new instance of Status.
7 8 9 |
# File 'lib/rgitflow/tasks/scm/status.rb', line 7 def initialize(git) super(git, 'status', 'Check the status of the repository', ['rgitflow', 'scm']) end |
Instance Method Details
#dirty? ⇒ Boolean (protected)
25 26 27 |
# File 'lib/rgitflow/tasks/scm/status.rb', line 25 def dirty? @git.diff.size > 0 end |
#print_status ⇒ Object (protected)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rgitflow/tasks/scm/status.rb', line 29 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' added.each { |f| debug " #{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" } debug 'modified' modified.each { |f| debug " #{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" } debug 'deleted' deleted.each { |f| debug " #{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT}#{f.path}#{ANSI::Constants::CLEAR}" } end |
#run ⇒ Object (protected)
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rgitflow/tasks/scm/status.rb', line 13 def run if dirty? error 'There are uncommitted changes in the repository!' print_status abort else status 'There are no uncommitted changes in the repository.' end end |