Skip to content

Commit 977b2db

Browse files
CM-55207-Move consts
1 parent 6759467 commit 977b2db

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cycode/cli/consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269

270270
# git consts
271271
COMMIT_DIFF_DELETED_FILE_CHANGE_TYPE = 'D'
272+
COMMIT_RANGE_ALL_COMMITS = '--all'
272273
GIT_HEAD_COMMIT_REV = 'HEAD'
273274
GIT_EMPTY_TREE_OBJECT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
274275
EMPTY_COMMIT_SHA = '0000000000000000000000000000000000000000'

cycode/cli/files_collector/commit_range_documents.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
logger = get_logger('Commit Range Collector')
2323

24-
COMMIT_RANGE_ALL = '--all'
25-
26-
2724
def get_safe_head_reference_for_diff(repo: 'Repo') -> str:
2825
"""Get a safe reference to use for diffing against the current HEAD.
2926
In repositories with no commits, HEAD doesn't exist, so we return the empty tree hash.
@@ -353,10 +350,10 @@ def calculate_pre_push_commit_range(push_update_details: str) -> Optional[str]:
353350
return f'{merge_base}..{local_object_name}'
354351

355352
logger.debug('Failed to find merge base with any default branch')
356-
return COMMIT_RANGE_ALL
353+
return consts.COMMIT_RANGE_ALL_COMMITS
357354
except Exception as e:
358355
logger.debug('Failed to get repo for pre-push commit range calculation: %s', exc_info=e)
359-
return COMMIT_RANGE_ALL
356+
return consts.COMMIT_RANGE_ALL_COMMITS
360357

361358
# If deleting a branch (local_object_name is all zeros), no need to scan
362359
if local_object_name == consts.EMPTY_COMMIT_SHA:
@@ -456,7 +453,7 @@ def parse_commit_range(commit_range: str, path: str) -> tuple[Optional[str], Opt
456453

457454
# Handle '--all' special case: scan all commits from first to HEAD
458455
# Usually represents an empty remote repository
459-
if commit_range == COMMIT_RANGE_ALL:
456+
if commit_range == consts.COMMIT_RANGE_ALL_COMMITS:
460457
try:
461458
head_commit = repo.rev_parse(consts.GIT_HEAD_COMMIT_REV).hexsha
462459
all_commits = repo.git.rev_list('--reverse', head_commit).strip()

0 commit comments

Comments
 (0)