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
|