mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
Pass a null device instead of explicitly closing stderr
When calling git any error messages should be suppressed (e.g. if an directory is not inside a git repository). Closing the stderr output when calling `IO.popen` works fine on POSIX systems, but on Windows it does not and spits out a warning for every invocation: ``` git.rb:44: warning: cannot close fd before spawn ``` Fixes #517.
This commit is contained in:
parent
c7aa167952
commit
60cf569776
2 changed files with 7 additions and 1 deletions
|
@ -52,7 +52,7 @@ module ColorLS
|
|||
|
||||
def git_prefix(repo_path)
|
||||
[
|
||||
IO.popen(['git', '-C', repo_path, 'rev-parse', '--show-prefix'], err: :close, &:gets)&.chomp,
|
||||
IO.popen(['git', '-C', repo_path, 'rev-parse', '--show-prefix'], err: File::NULL, &:gets)&.chomp,
|
||||
$CHILD_STATUS.success?
|
||||
]
|
||||
rescue Errno::ENOENT
|
||||
|
|
|
@ -39,4 +39,10 @@ RSpec.describe ColorLS::Git do
|
|||
expect(subject.status('/repo/')).to include('subdir' => Set['M', 'D'])
|
||||
end
|
||||
end
|
||||
|
||||
context 'determining the git status' do
|
||||
it 'does not output to stderr' do
|
||||
expect { subject.status('.') }.not_to output.to_stderr
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue