Skip to content

Commit 7ad9a16

Browse files
committed
fix: prioritize maintenance branch detection over explicit base_ref
- Ensure maintenance branches (.x) always use 'git show HEAD' - Prevents fallback to git diff strategies that fail with shallow checkouts - Fixes issue where --base parameter overrode maintenance branch logic
1 parent cc2b0cf commit 7ad9a16

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.github/scripts/test_discovery.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def _get_changed_files(self, base_ref: Optional[str] = None) -> List[str]:
6262
pr_head = os.environ.get('GITHUB_HEAD_HEAD') # PRs
6363
branch = os.environ.get('GITHUB_REF_NAME') # pushes
6464

65-
# For maintenance branches (cherry-picks), always use single commit diff
65+
# For maintenance branches (cherry-picks), always use git show HEAD regardless of base_ref
6666
if branch and branch.endswith('.x'):
67-
# Maintenance branch - cherry-picks are always single commits
68-
cmd = ["git", "diff", "--name-only", "HEAD~1..HEAD"]
67+
# Maintenance branch - cherry-picks are single commits, just get files in this commit
68+
cmd = ["git", "show", "--name-only", "--format=", "HEAD"]
6969
elif base_ref:
7070
# Explicit base reference provided - use two-dot diff for direct comparison
7171
cmd = ["git", "diff", "--name-only", f"{base_ref}..HEAD"]
@@ -180,7 +180,7 @@ def _detect_default_base(self) -> str:
180180

181181
# Show the actual strategy being used
182182
if branch and branch.endswith('.x'):
183-
return f"HEAD~1 (single commit - maintenance branch {branch})"
183+
return f"git show HEAD (maintenance branch {branch})"
184184
elif pr_base:
185185
return f"origin/{pr_base} (PR base)"
186186
elif branch:

0 commit comments

Comments
 (0)