Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 5e9373d

Browse files
committed
Merge pull request #71 from bklang/patch-1
Quote git_dir when used in git command execution
2 parents fa5298a + 03ec58a commit 5e9373d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/code_climate/test_reporter/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def branch_from_git
4545
end
4646

4747
def git(command)
48-
`git --git-dir=#{git_dir}/.git #{command}`
48+
`git --git-dir="#{git_dir}/.git" #{command}`
4949
end
5050

5151
def git_dir

spec/lib/git_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ module CodeClimate::TestReporter
1414
end
1515
end
1616

17+
describe 'git' do
18+
it 'should quote the git repository directory' do
19+
path = '/path/to/foo bar'
20+
21+
allow(CodeClimate::TestReporter.configuration).to receive(:git_dir).and_return path
22+
expect(Git).to receive(:`).once.with "git --git-dir=\"#{path}/.git\" help"
23+
24+
Git.send :git, 'help'
25+
end
26+
end
27+
1728
describe 'branch_from_git_or_ci' do
1829
it 'returns the branch from ci' do
1930
allow(Ci).to receive(:service_data).and_return({branch: 'ci-branch'})

0 commit comments

Comments
 (0)