Module: ColorLS::Git
- Defined in:
- lib/colorls/git.rb
Class Method Summary collapse
Class Method Details
.colored_status_symbols(modes, colors) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/colorls/git.rb', line 36 def self.colored_status_symbols(modes, colors) if modes.empty? return ' ✓ ' .encode(Encoding.default_external, undef: :replace, replace: '=') .colorize(colors[:unchanged]) end modes.to_a.join.uniq.delete('!').rjust(3).ljust(4) .sub('?', '?'.colorize(colors[:untracked])) .sub('A', 'A'.colorize(colors[:addition])) .sub('M', 'M'.colorize(colors[:modification])) .sub('D', 'D'.colorize(colors[:deletion])) end |
.status(repo_path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/colorls/git.rb', line 11 def self.status(repo_path) prefix, success = git_prefix(repo_path) return unless success prefix_path = Pathname.new(prefix) git_status = Hash.new { |hash, key| hash[key] = Set.new } git_status_default = EMPTY_SET git_subdir_status(repo_path) do |mode, file| if file == prefix git_status_default = Set[mode].freeze else path = Pathname.new(file).relative_path_from(prefix_path) git_status[path.descend.first.cleanpath.to_s].add(mode) end end warn "git status failed in #{repo_path}" unless $CHILD_STATUS.success? git_status.default = git_status_default git_status.freeze end |