@@ -351,10 +351,10 @@ def calculate_pre_push_commit_range(push_update_details: str) -> Optional[str]:
351351 return f'{ merge_base } ..{ local_object_name } '
352352
353353 logger .debug ('Failed to find merge base with any default branch' )
354- return '--all'
354+ return consts . COMMIT_RANGE_ALL_COMMITS
355355 except Exception as e :
356356 logger .debug ('Failed to get repo for pre-push commit range calculation: %s' , exc_info = e )
357- return '--all'
357+ return consts . COMMIT_RANGE_ALL_COMMITS
358358
359359 # If deleting a branch (local_object_name is all zeros), no need to scan
360360 if local_object_name == consts .EMPTY_COMMIT_SHA :
@@ -448,9 +448,25 @@ def parse_commit_range(commit_range: str, path: str) -> tuple[Optional[str], Opt
448448 - 'commit' (interpreted as 'commit..HEAD')
449449 - '..to' (interpreted as 'HEAD..to')
450450 - 'from..' (interpreted as 'from..HEAD')
451+ - '--all' (interpreted as 'first_commit..HEAD' to scan all commits)
451452 """
452453 repo = git_proxy .get_repo (path )
453454
455+ # Handle '--all' special case: scan all commits from first to HEAD
456+ # Usually represents an empty remote repository
457+ if commit_range == consts .COMMIT_RANGE_ALL_COMMITS :
458+ try :
459+ head_commit = repo .rev_parse (consts .GIT_HEAD_COMMIT_REV ).hexsha
460+ all_commits = repo .git .rev_list ('--reverse' , head_commit ).strip ()
461+ if all_commits :
462+ first_commit = all_commits .splitlines ()[0 ]
463+ return first_commit , head_commit , '..'
464+ logger .warning ("No commits found for range '%s'" , commit_range )
465+ return None , None , None
466+ except Exception as e :
467+ logger .warning ("Failed to parse commit range '%s'" , commit_range , exc_info = e )
468+ return None , None , None
469+
454470 separator = '..'
455471 if '...' in commit_range :
456472 from_spec , to_spec = commit_range .split ('...' , 1 )
0 commit comments