2828from testing .fixtures import remove_config_from_repo
2929from testing .util import cmd_output_mocked_pre_commit_home
3030from testing .util import cwd
31+ from testing .util import git_commit
3132from testing .util import xfailif_no_symlink
3233
3334
@@ -109,7 +110,7 @@ def _get_commit_output(tempdir_factory, touch_file='foo', **kwargs):
109110 open (touch_file , 'a' ).close ()
110111 cmd_output ('git' , 'add' , touch_file )
111112 return cmd_output_mocked_pre_commit_home (
112- 'git' , 'commit' , '-am' , commit_msg , '--allow-empty' ,
113+ 'git' , 'commit' , '-am' , commit_msg , '--allow-empty' , '--no-gpg-sign' ,
113114 # git commit puts pre-commit to stderr
114115 stderr = subprocess .STDOUT ,
115116 retcode = None ,
@@ -151,7 +152,7 @@ def test_install_pre_commit_and_run_custom_path(tempdir_factory, store):
151152 path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
152153 with cwd (path ):
153154 cmd_output ('git' , 'mv' , C .CONFIG_FILE , 'custom-config.yaml' )
154- cmd_output ( 'git' , 'commit' , '-m' , 'move pre-commit config' )
155+ git_commit ( 'move pre-commit config' )
155156 assert install ('custom-config.yaml' , store ) == 0
156157
157158 ret , output = _get_commit_output (tempdir_factory )
@@ -163,7 +164,7 @@ def test_install_in_submodule_and_run(tempdir_factory, store):
163164 src_path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
164165 parent_path = git_dir (tempdir_factory )
165166 cmd_output ('git' , 'submodule' , 'add' , src_path , 'sub' , cwd = parent_path )
166- cmd_output ( 'git' , 'commit' , '-m' , 'foo' , cwd = parent_path )
167+ git_commit ( 'foo' , cwd = parent_path )
167168
168169 sub_pth = os .path .join (parent_path , 'sub' )
169170 with cwd (sub_pth ):
@@ -193,7 +194,7 @@ def test_commit_am(tempdir_factory, store):
193194 # Make an unstaged change
194195 open ('unstaged' , 'w' ).close ()
195196 cmd_output ('git' , 'add' , '.' )
196- cmd_output ( 'git' , 'commit' , '-m' , 'foo' )
197+ git_commit ( 'foo' )
197198 with io .open ('unstaged' , 'w' ) as foo_file :
198199 foo_file .write ('Oh hai' )
199200
@@ -208,12 +209,12 @@ def test_unicode_merge_commit_message(tempdir_factory, store):
208209 with cwd (path ):
209210 assert install (C .CONFIG_FILE , store ) == 0
210211 cmd_output ('git' , 'checkout' , 'master' , '-b' , 'foo' )
211- cmd_output ( 'git ' , 'commit' , '--allow-empty' , '-n' , '-m' , 'branch2 ' )
212+ git_commit ( 'branch2 ' , '-n ' )
212213 cmd_output ('git' , 'checkout' , 'master' )
213214 cmd_output ('git' , 'merge' , 'foo' , '--no-ff' , '--no-commit' , '-m' , '☃' )
214215 # Used to crash
215216 cmd_output_mocked_pre_commit_home (
216- 'git' , 'commit' , '--no-edit' ,
217+ 'git' , 'commit' , '--no-edit' , '--no-gpg-sign' ,
217218 tempdir_factory = tempdir_factory ,
218219 )
219220
@@ -246,8 +247,8 @@ def test_environment_not_sourced(tempdir_factory, store):
246247
247248 # Use a specific homedir to ignore --user installs
248249 homedir = tempdir_factory .get ()
249- ret , stdout , stderr = cmd_output (
250- 'git' , 'commit' , '--allow-empty' , '-m' , ' foo' ,
250+ ret , stdout , stderr = git_commit (
251+ 'foo' ,
251252 env = {
252253 'HOME' : homedir ,
253254 'PATH' : _path_without_us (),
0 commit comments