@@ -392,15 +392,15 @@ def test_parse_branch_deletion_input(self) -> None:
392392 result = parse_pre_push_input ()
393393 assert result == pre_push_input
394394
395- def test_parse_empty_input_raises_error (self ) -> None :
396- """Test that empty input raises ValueError ."""
397- with patch ('sys.stdin' , StringIO ('' )), pytest . raises ( ValueError , match = 'Pre push input was not found' ) :
398- parse_pre_push_input ()
395+ def test_parse_empty_input_returns_none (self ) -> None :
396+ """Test that empty input returns None instead of raising ."""
397+ with patch ('sys.stdin' , StringIO ('' )):
398+ assert parse_pre_push_input () is None
399399
400- def test_parse_whitespace_only_input_raises_error (self ) -> None :
401- """Test that whitespace-only input raises ValueError ."""
402- with patch ('sys.stdin' , StringIO (' \n \t ' )), pytest . raises ( ValueError , match = 'Pre push input was not found' ) :
403- parse_pre_push_input ()
400+ def test_parse_whitespace_only_input_returns_none (self ) -> None :
401+ """Test that whitespace-only input returns None instead of raising ."""
402+ with patch ('sys.stdin' , StringIO (' \n \t ' )):
403+ assert parse_pre_push_input () is None
404404
405405
406406class TestGetDefaultBranchesForMergeBase :
@@ -758,26 +758,23 @@ def test_calculate_range_parsing_push_details(self) -> None:
758758 result = calculate_pre_push_commit_range (push_details )
759759 assert result == '789xyz456abc..abc123def456'
760760
761- def test_calculate_range_with_tags (self ) -> None :
762- """Test calculating commit range when pushing tags ."""
761+ def test_calculate_range_with_new_tag_push_returns_none (self ) -> None :
762+ """Test that pushing a new tag returns None (no scanning needed) ."""
763763 push_details = f'refs/tags/v1.0.0 1234567890abcdef refs/tags/v1.0.0 { consts .EMPTY_COMMIT_SHA } '
764+ result = calculate_pre_push_commit_range (push_details )
765+ assert result is None
764766
765- with temporary_git_repository () as (temp_dir , repo ):
766- # Create a commit
767- test_file = os .path .join (temp_dir , 'test.py' )
768- with open (test_file , 'w' ) as f :
769- f .write ("print('test')" )
770-
771- repo .index .add (['test.py' ])
772- commit = repo .index .commit ('Test commit' )
773-
774- # Create tag
775- repo .create_tag ('v1.0.0' , commit )
767+ def test_calculate_range_with_tag_deletion_returns_none (self ) -> None :
768+ """Test that deleting a tag returns None (no scanning needed)."""
769+ push_details = f'refs/tags/v1.0.0 { consts .EMPTY_COMMIT_SHA } refs/tags/v1.0.0 1234567890abcdef'
770+ result = calculate_pre_push_commit_range (push_details )
771+ assert result is None
776772
777- with patch ('os.getcwd' , return_value = temp_dir ):
778- result = calculate_pre_push_commit_range (push_details )
779- # For new tags, should try to find a merge base or fall back to --all
780- assert result in [f'{ commit .hexsha } ..{ commit .hexsha } ' , '--all' ]
773+ def test_calculate_range_with_tag_update_returns_none (self ) -> None :
774+ """Test that updating a tag returns None (no scanning needed)."""
775+ push_details = 'refs/tags/v1.0.0 1234567890abcdef refs/tags/v1.0.0 0987654321fedcba'
776+ result = calculate_pre_push_commit_range (push_details )
777+ assert result is None
781778
782779
783780class TestPrePushHookIntegration :
@@ -805,12 +802,15 @@ def test_simulate_pre_push_hook_input_format(self) -> None:
805802 # Test that we can calculate the commit range for each case
806803 commit_range = calculate_pre_push_commit_range (parsed )
807804
808- if consts .EMPTY_COMMIT_SHA in push_input :
809- if push_input .startswith ('refs/heads/' ) and push_input .split ()[1 ] == consts .EMPTY_COMMIT_SHA :
805+ if push_input .startswith ('refs/tags/' ):
806+ # Tag pushes - should return None (no scanning needed)
807+ assert commit_range is None
808+ elif consts .EMPTY_COMMIT_SHA in push_input :
809+ if push_input .split ()[1 ] == consts .EMPTY_COMMIT_SHA :
810810 # Branch deletion - should return None
811811 assert commit_range is None
812812 else :
813- # New branch/tag - should return a range or --all
813+ # New branch - should return a range or --all
814814 assert commit_range is not None
815815 else :
816816 # Regular update - should return proper range
0 commit comments