@@ -495,13 +495,13 @@ def test_installed_from_venv(tempdir_factory, store):
495495 assert NORMAL_PRE_COMMIT_RUN .match (output )
496496
497497
498- def _get_push_output (tempdir_factory ):
498+ def _get_push_output (tempdir_factory , opts = () ):
499499 return cmd_output_mocked_pre_commit_home (
500- 'git' , 'push' , 'origin' , 'HEAD:new_branch' ,
500+ 'git' , 'push' , 'origin' , 'HEAD:new_branch' , * opts ,
501501 # git push puts pre-commit to stderr
502502 stderr = subprocess .STDOUT ,
503503 tempdir_factory = tempdir_factory ,
504- retcode = None ,
504+ retcode = None
505505 )[:2 ]
506506
507507
@@ -535,6 +535,26 @@ def test_pre_push_integration_accepted(tempdir_factory, store):
535535 assert 'Passed' in output
536536
537537
538+ def test_pre_push_force_push_without_fetch (tempdir_factory , store ):
539+ upstream = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
540+ path1 = tempdir_factory .get ()
541+ path2 = tempdir_factory .get ()
542+ cmd_output ('git' , 'clone' , upstream , path1 )
543+ cmd_output ('git' , 'clone' , upstream , path2 )
544+ with cwd (path1 ):
545+ assert _get_commit_output (tempdir_factory )[0 ] == 0
546+ assert _get_push_output (tempdir_factory )[0 ] == 0
547+
548+ with cwd (path2 ):
549+ install (Runner (path2 , C .CONFIG_FILE ), store , hook_type = 'pre-push' )
550+ assert _get_commit_output (tempdir_factory , commit_msg = 'force!' )[0 ] == 0
551+
552+ retc , output = _get_push_output (tempdir_factory , opts = ('--force' ,))
553+ assert retc == 0
554+ assert 'Bash hook' in output
555+ assert 'Passed' in output
556+
557+
538558def test_pre_push_new_upstream (tempdir_factory , store ):
539559 upstream = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
540560 upstream2 = git_dir (tempdir_factory )
0 commit comments