Module: ColorLS::Git
- Defined in:
- lib/colorls/git.rb
Class Method Summary collapse
Class Method Details
.colored_status_symbols(modes, colors) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/colorls/git.rb', line 33 def self.colored_status_symbols(modes, colors) return ' ✓ '.colorize(colors[:unchanged]) if modes.empty? modes = modes.to_a.join.uniq.rjust(3).ljust(4) modes .gsub('?', '?'.colorize(colors[:untracked])) .gsub('A', 'A'.colorize(colors[:addition])) .gsub('M', 'M'.colorize(colors[:modification])) .gsub('D', 'D'.colorize(colors[:deletion])) .tr('!', ' ') end |
.status(repo_path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/colorls/git.rb', line 7 def self.status(repo_path) prefix = git_prefix(repo_path) return unless $CHILD_STATUS.success? prefix = Pathname.new(prefix.chomp) git_status = Hash.new { |hash, key| hash[key] = Set.new } git_subdir_status(repo_path) do |output| while (status_line = output.gets "\x0") mode, file = status_line.chomp("\x0").split(' ', 2) path = Pathname.new(file).relative_path_from(prefix) git_status[path.descend.first.cleanpath.to_s].add(mode) # skip the next \x0 separated original path for renames, issue #185 output.gets("\x0") if mode.start_with? 'R' end end warn "git status failed in #{repo_path}" unless $CHILD_STATUS.success? git_status end |