@@ -106,11 +106,10 @@ def test_uninstall(in_git_dir, store):
106106
107107
108108def _get_commit_output (tempdir_factory , touch_file = 'foo' , ** kwargs ):
109- commit_msg = kwargs .pop ('commit_msg' , 'Commit!' )
110109 open (touch_file , 'a' ).close ()
111110 cmd_output ('git' , 'add' , touch_file )
112- return cmd_output_mocked_pre_commit_home (
113- 'git' , 'commit' , '-am' , commit_msg , '--allow-empty' , '--no-gpg-sign' ,
111+ return git_commit (
112+ fn = cmd_output_mocked_pre_commit_home ,
114113 # git commit puts pre-commit to stderr
115114 stderr = subprocess .STDOUT ,
116115 retcode = None ,
@@ -132,7 +131,7 @@ def _get_commit_output(tempdir_factory, touch_file='foo', **kwargs):
132131NORMAL_PRE_COMMIT_RUN = re .compile (
133132 r'^\[INFO\] Initializing environment for .+\.\r?\n'
134133 r'Bash hook\.+Passed\r?\n'
135- r'\[master [a-f0-9]{7}\] Commit !\r?\n' +
134+ r'\[master [a-f0-9]{7}\] commit !\r?\n' +
136135 FILES_CHANGED +
137136 r' create mode 100644 foo\r?\n$' ,
138137)
@@ -152,7 +151,7 @@ def test_install_pre_commit_and_run_custom_path(tempdir_factory, store):
152151 path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
153152 with cwd (path ):
154153 cmd_output ('git' , 'mv' , C .CONFIG_FILE , 'custom-config.yaml' )
155- git_commit ('move pre-commit config' )
154+ git_commit (cwd = path )
156155 assert install ('custom-config.yaml' , store ) == 0
157156
158157 ret , output = _get_commit_output (tempdir_factory )
@@ -164,7 +163,7 @@ def test_install_in_submodule_and_run(tempdir_factory, store):
164163 src_path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
165164 parent_path = git_dir (tempdir_factory )
166165 cmd_output ('git' , 'submodule' , 'add' , src_path , 'sub' , cwd = parent_path )
167- git_commit ('foo' , cwd = parent_path )
166+ git_commit (cwd = parent_path )
168167
169168 sub_pth = os .path .join (parent_path , 'sub' )
170169 with cwd (sub_pth ):
@@ -194,7 +193,7 @@ def test_commit_am(tempdir_factory, store):
194193 # Make an unstaged change
195194 open ('unstaged' , 'w' ).close ()
196195 cmd_output ('git' , 'add' , '.' )
197- git_commit ('foo' )
196+ git_commit (cwd = path )
198197 with io .open ('unstaged' , 'w' ) as foo_file :
199198 foo_file .write ('Oh hai' )
200199
@@ -209,12 +208,14 @@ def test_unicode_merge_commit_message(tempdir_factory, store):
209208 with cwd (path ):
210209 assert install (C .CONFIG_FILE , store ) == 0
211210 cmd_output ('git' , 'checkout' , 'master' , '-b' , 'foo' )
212- git_commit ('branch2' , ' -n' )
211+ git_commit ('-n' , cwd = path )
213212 cmd_output ('git' , 'checkout' , 'master' )
214213 cmd_output ('git' , 'merge' , 'foo' , '--no-ff' , '--no-commit' , '-m' , '☃' )
215214 # Used to crash
216- cmd_output_mocked_pre_commit_home (
217- 'git' , 'commit' , '--no-edit' , '--no-gpg-sign' ,
215+ git_commit (
216+ '--no-edit' ,
217+ msg = None ,
218+ fn = cmd_output_mocked_pre_commit_home ,
218219 tempdir_factory = tempdir_factory ,
219220 )
220221
@@ -248,7 +249,6 @@ def test_environment_not_sourced(tempdir_factory, store):
248249 # Use a specific homedir to ignore --user installs
249250 homedir = tempdir_factory .get ()
250251 ret , stdout , stderr = git_commit (
251- 'foo' ,
252252 env = {
253253 'HOME' : homedir ,
254254 'PATH' : _path_without_us (),
@@ -291,7 +291,7 @@ def test_failing_hooks_returns_nonzero(tempdir_factory, store):
291291
292292EXISTING_COMMIT_RUN = re .compile (
293293 r'^legacy hook\r?\n'
294- r'\[master [a-f0-9]{7}\] Commit !\r?\n' +
294+ r'\[master [a-f0-9]{7}\] commit !\r?\n' +
295295 FILES_CHANGED +
296296 r' create mode 100644 baz\r?\n$' ,
297297)
@@ -434,7 +434,7 @@ def test_uninstall_doesnt_remove_not_our_hooks(in_git_dir):
434434
435435PRE_INSTALLED = re .compile (
436436 r'Bash hook\.+Passed\r?\n'
437- r'\[master [a-f0-9]{7}\] Commit !\r?\n' +
437+ r'\[master [a-f0-9]{7}\] commit !\r?\n' +
438438 FILES_CHANGED +
439439 r' create mode 100644 foo\r?\n$' ,
440440)
@@ -546,7 +546,7 @@ def test_pre_push_force_push_without_fetch(tempdir_factory, store):
546546
547547 with cwd (path2 ):
548548 install (C .CONFIG_FILE , store , hook_type = 'pre-push' )
549- assert _get_commit_output (tempdir_factory , commit_msg = 'force!' )[0 ] == 0
549+ assert _get_commit_output (tempdir_factory , msg = 'force!' )[0 ] == 0
550550
551551 retc , output = _get_push_output (tempdir_factory , opts = ('--force' ,))
552552 assert retc == 0
@@ -625,7 +625,7 @@ def test_commit_msg_integration_passing(
625625):
626626 install (C .CONFIG_FILE , store , hook_type = 'commit-msg' )
627627 msg = 'Hi\n Signed off by: me, lol'
628- retc , out = _get_commit_output (tempdir_factory , commit_msg = msg )
628+ retc , out = _get_commit_output (tempdir_factory , msg = msg )
629629 assert retc == 0
630630 first_line = out .splitlines ()[0 ]
631631 assert first_line .startswith ('Must have "Signed off by:"...' )
@@ -647,7 +647,7 @@ def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store):
647647 install (C .CONFIG_FILE , store , hook_type = 'commit-msg' )
648648
649649 msg = 'Hi\n Signed off by: asottile'
650- retc , out = _get_commit_output (tempdir_factory , commit_msg = msg )
650+ retc , out = _get_commit_output (tempdir_factory , msg = msg )
651651 assert retc == 0
652652 first_line , second_line = out .splitlines ()[:2 ]
653653 assert first_line == 'legacy'
0 commit comments