Skip to content

Commit 11107bd

Browse files
authored
Fix git processing (#337)
Fix regression in 1.3.x where git status handling was broken.
2 parents 6c51cd9 + fb39a9d commit 11107bd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Metrics/BlockLength:
4242
Exclude:
4343
- 'spec/**/*'
4444

45-
Metrics/LineLength:
45+
Layout/LineLength:
4646
Max: 120
4747

4848
Metrics/ModuleLength:

lib/colorls/core.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,14 @@ def git_dir_info(path)
248248
modes = if path == '.'
249249
Set.new(@git_status.values).flatten
250250
else
251-
@git_status.fetch(path, nil)
251+
@git_status[path]
252252
end
253253

254-
return Git.colored_status_symbols(modes, @colors) unless modes.nil?
255-
256-
' '
254+
if modes.empty? && Dir.empty?(File.join(@input, path))
255+
' '
256+
else
257+
Git.colored_status_symbols(modes, @colors)
258+
end
257259
end
258260

259261
def long_info(content)

lib/colorls/git.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def git_prefix(repo_path)
5151
end
5252

5353
def git_subdir_status(repo_path)
54-
IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-unormal', '--ignored', '.'])
54+
yield IO.popen(['git', '-C', repo_path, 'status', '--porcelain', '-z', '-unormal', '--ignored', '.'])
5555
end
5656
end
5757
end

0 commit comments

Comments
 (0)