diff --git a/lib/colorls/git.rb b/lib/colorls/git.rb index 3b2102b..cf3f75d 100644 --- a/lib/colorls/git.rb +++ b/lib/colorls/git.rb @@ -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 diff --git a/spec/color_ls/git_spec.rb b/spec/color_ls/git_spec.rb index 317971e..65ee927 100644 --- a/spec/color_ls/git_spec.rb +++ b/spec/color_ls/git_spec.rb @@ -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