Module: ColorLS::Git
- Defined in:
- lib/colorls/git.rb
Class Method Summary collapse
Class Method Details
.colored_status_symbols(modes, colors) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/colorls/git.rb', line 32 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/colorls/git.rb', line 8 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_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 = Set.new.freeze if git_status.default.nil? git_status.freeze end |