Class: Gb::Status
- Inherits:
-
SubCommand
- Object
- CLAide::Command
- Command
- SubCommand
- Gb::Status
- Defined in:
- lib/commands/status.rb
Instance Attribute Summary
Attributes inherited from SubCommand
Instance Method Summary collapse
Methods inherited from SubCommand
#check_uncommit, #initialize, #run, #save_workspace_config, #validate!, #workspace_config
Methods inherited from Command
#error, handle_exception, #info, report_error, run
Constructor Details
This class inherits a constructor from Gb::SubCommand
Instance Method Details
#run_in_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/commands/status.rb', line 14 def run_in_config workspace_config = self.workspace_config info "current work branch '#{workspace_config.work_branch}'" info "track remote branch '#{workspace_config.remote_branch}'." puts self.gb_config.projects.each do |project| project_path = File.(project.name, './') if File.exist?(project_path) info "for project '#{project.name}'..." g = Git.open(project_path) if workspace_config.work_branch != g.current_branch error "current branch(#{g.current_branch}) is not work branch." puts end changed = g.status.changed added = g.status.added deleted = g.status.deleted untracked = g.status.untracked if !changed.empty? alert = true puts "modified files:".red changed.each do |file, status| puts (" M: " << file).red end end if !added.empty? alert = true puts "added files:".red added.each do |file, status| puts (" A: " << file).red end end if !deleted.empty? alert = true puts "deleted files:".red deleted.each do |file, status| puts (" D: " << file).red end end if !untracked.empty? alert = true puts "untracked files:".red untracked.each do |file, status| puts (" " << file).red end end if alert else info "git工作区无代码要提交" end puts else error "please run 'gb init first." break end end end |