Skip to content

Commit 0da3d16

Browse files
committed
Use double-quotes in shell commands
Windows command prompt does not recognize single-quotes as string delimiters. Use double-quotes instead.
1 parent 8583ad3 commit 0da3d16

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

lib/overcommit/git_repo.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def extract_modified_lines(file_path, options)
6969
refs = options[:refs]
7070
subcmd = options[:subcmd] || 'diff'
7171

72-
`git #{subcmd} --no-ext-diff -U0 #{flags} #{refs} -- '#{file_path}'`.
72+
`git #{subcmd} --no-ext-diff -U0 #{flags} #{refs} -- "#{file_path}"`.
7373
scan(DIFF_HUNK_REGEX) do |start_line, lines_added|
7474
lines_added = (lines_added || 1).to_i # When blank, one line was added
7575
cur_line = start_line.to_i

lib/overcommit/hook/pre_commit/author_name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def run
88
unless name.split(' ').count >= 2
99
return :fail,
1010
"Author must have at least first and last name, but was: #{name}." \
11-
"\nSet your name with `git config --global user.name 'Your Name'`"
11+
'\nSet your name with `git config --global user.name "Your Name"`'
1212
end
1313

1414
:pass

lib/overcommit/hook_context/pre_commit.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def amendment?
2020
@amendment = !(/\s#{amend_pattern}/ =~ cmd).nil?
2121

2222
# Check for git aliases that call `commit --amend`
23-
`git config --get-regexp '^alias\\.' '#{amend_pattern}'`.
23+
`git config --get-regexp "^alias\\." "#{amend_pattern}"`.
2424
scan(/alias\.([-\w]+)/). # Extract the alias
2525
each do |match|
2626
return @amendment if

spec/integration/committing_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
context 'when a hook fails' do
2727
before do
28-
`git config --local user.name ''`
28+
`git config --local user.name ""`
2929
end
3030

3131
it 'exits with a non-zero status' do
@@ -35,7 +35,7 @@
3535

3636
context 'when no hooks fail' do
3737
before do
38-
`git config --local user.name 'John Doe'`
38+
`git config --local user.name "John Doe"`
3939
end
4040

4141
it 'exits successfully' do

spec/overcommit/hook_context/post_commit_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
repo do
5454
FileUtils.touch('some-file')
5555
`git add some-file`
56-
`git commit -m 'Initial commit'`
56+
`git commit -m "Initial commit"`
5757
`echo Hello > some-file`
5858
`git add some-file`
59-
`git commit -m 'Modify some-file'`
59+
`git commit -m "Modify some-file"`
6060
example.run
6161
end
6262
end
@@ -69,9 +69,9 @@
6969
repo do
7070
FileUtils.touch('some-file')
7171
`git add some-file`
72-
`git commit -m 'Initial commit'`
72+
`git commit -m "Initial commit"`
7373
`git rm some-file`
74-
`git commit -m 'Delete some-file'`
74+
`git commit -m "Delete some-file"`
7575
example.run
7676
end
7777
end

spec/overcommit/hook_context/post_merge_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
repo do
138138
FileUtils.touch('some-file')
139139
`git add some-file`
140-
`git commit -m 'Initial commit'`
140+
`git commit -m "Initial commit"`
141141
`git checkout -b child > #{File::NULL} 2>&1`
142142
`echo Hello > some-file`
143143
`git add some-file`
@@ -156,7 +156,7 @@
156156
repo do
157157
FileUtils.touch('some-file')
158158
`git add some-file`
159-
`git commit -m 'Initial commit'`
159+
`git commit -m "Initial commit"`
160160
`git checkout -b child > #{File::NULL} 2>&1`
161161
`git rm some-file`
162162
`git commit -m "Branch commit"`

spec/overcommit/hook_context/pre_commit_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
context 'when amending a commit using a git alias' do
2424
around do |example|
2525
repo do
26-
`git config alias.amend 'commit --amend'`
27-
`git config alias.other-amend 'commit --amend'`
26+
`git config alias.amend "commit --amend"`
27+
`git config alias.other-amend "commit --amend"`
2828
example.run
2929
end
3030
end
@@ -183,8 +183,8 @@
183183
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
184184
`git commit -m "Add submodule"`
185185
`echo "Hello World" > sub/submodule-file`
186-
`git submodule foreach 'git add submodule-file'`
187-
`git submodule foreach 'git commit -m "Another commit"'`
186+
`git submodule foreach "git add submodule-file"`
187+
`git submodule foreach "git commit -m \\"Another commit\\""`
188188
`git add sub`
189189
example.run
190190
end
@@ -333,8 +333,8 @@
333333
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
334334
`git commit -m "Add submodule"`
335335
`echo "Hello World" > sub/submodule-file`
336-
`git submodule foreach 'git add submodule-file'`
337-
`git submodule foreach 'git commit -m "Another commit"'`
336+
`git submodule foreach "git add submodule-file"`
337+
`git submodule foreach "git commit -m \\"Another commit\\""`
338338
`git add sub`
339339
example.run
340340
end
@@ -357,8 +357,8 @@
357357
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
358358
`git commit -m "Add submodule"`
359359
`echo "Hello World" > sub/submodule-file`
360-
`git submodule foreach 'git add submodule-file'`
361-
`git submodule foreach 'git commit -m "Another commit"'`
360+
`git submodule foreach "git add submodule-file"`
361+
`git submodule foreach "git commit -m \\"Another commit\\""`
362362
`echo "Hello Again" > tracked-file`
363363
`git add sub tracked-file`
364364
example.run
@@ -445,7 +445,7 @@
445445
repo do
446446
FileUtils.touch('some-file')
447447
`git add some-file`
448-
`git commit -m 'Initial commit'`
448+
`git commit -m "Initial commit"`
449449
`echo Hello > some-file`
450450
`git add some-file`
451451
example.run
@@ -460,7 +460,7 @@
460460
repo do
461461
FileUtils.touch('some-file')
462462
`git add some-file`
463-
`git commit -m 'Initial commit'`
463+
`git commit -m "Initial commit"`
464464
`git rm some-file`
465465
example.run
466466
end
@@ -474,7 +474,7 @@
474474
repo do
475475
FileUtils.touch('some-file')
476476
`git add some-file`
477-
`git commit -m 'Initial commit'`
477+
`git commit -m "Initial commit"`
478478
FileUtils.touch('other-file')
479479
`git add other-file`
480480
example.run

0 commit comments

Comments
 (0)