@@ -655,7 +655,65 @@ def test_commit_msg_legacy(commit_msg_repo, tempdir_factory, store):
655655 assert second_line .startswith ('Must have "Signed off by:"...' )
656656
657657
658- def test_install_disallow_mising_config (tempdir_factory , store ):
658+ def test_prepare_commit_msg_integration_failing (
659+ failing_prepare_commit_msg_repo , tempdir_factory , store ,
660+ ):
661+ install (C .CONFIG_FILE , store , hook_type = 'prepare-commit-msg' )
662+ retc , out = _get_commit_output (tempdir_factory )
663+ assert retc == 1
664+ assert out .startswith ('Add "Signed off by:"...' )
665+ assert out .strip ().endswith ('...Failed' )
666+
667+
668+ def test_prepare_commit_msg_integration_passing (
669+ prepare_commit_msg_repo , tempdir_factory , store ,
670+ ):
671+ install (C .CONFIG_FILE , store , hook_type = 'prepare-commit-msg' )
672+ msg = 'Hi'
673+ retc , out = _get_commit_output (tempdir_factory , msg = msg )
674+ assert retc == 0
675+ first_line = out .splitlines ()[0 ]
676+ assert first_line .startswith ('Add "Signed off by:"...' )
677+ assert first_line .endswith ('...Passed' )
678+ commit_msg_path = os .path .join (
679+ prepare_commit_msg_repo , '.git/COMMIT_EDITMSG' ,
680+ )
681+ with io .open (commit_msg_path , 'rt' ) as f :
682+ assert 'Signed off by: ' in f .read ()
683+
684+
685+ def test_prepare_commit_msg_legacy (
686+ prepare_commit_msg_repo , tempdir_factory , store ,
687+ ):
688+ hook_path = os .path .join (
689+ prepare_commit_msg_repo , '.git/hooks/prepare-commit-msg' ,
690+ )
691+ mkdirp (os .path .dirname (hook_path ))
692+ with io .open (hook_path , 'w' ) as hook_file :
693+ hook_file .write (
694+ '#!/usr/bin/env bash\n '
695+ 'set -eu\n '
696+ 'test -e "$1"\n '
697+ 'echo legacy\n ' ,
698+ )
699+ make_executable (hook_path )
700+
701+ install (C .CONFIG_FILE , store , hook_type = 'prepare-commit-msg' )
702+
703+ msg = 'Hi'
704+ retc , out = _get_commit_output (tempdir_factory , msg = msg )
705+ assert retc == 0
706+ first_line , second_line = out .splitlines ()[:2 ]
707+ assert first_line == 'legacy'
708+ assert second_line .startswith ('Add "Signed off by:"...' )
709+ commit_msg_path = os .path .join (
710+ prepare_commit_msg_repo , '.git/COMMIT_EDITMSG' ,
711+ )
712+ with io .open (commit_msg_path , 'rt' ) as f :
713+ assert 'Signed off by: ' in f .read ()
714+
715+
716+ def test_install_disallow_missing_config (tempdir_factory , store ):
659717 path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
660718 with cwd (path ):
661719 remove_config_from_repo (path )
@@ -668,7 +726,7 @@ def test_install_disallow_mising_config(tempdir_factory, store):
668726 assert ret == 1
669727
670728
671- def test_install_allow_mising_config (tempdir_factory , store ):
729+ def test_install_allow_missing_config (tempdir_factory , store ):
672730 path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
673731 with cwd (path ):
674732 remove_config_from_repo (path )
0 commit comments