Skip to content

Commit 007809b

Browse files
committed
fix: simplify git strategy to use 'git show HEAD' for maintenance branches
- Remove complex HEAD~1..HEAD logic that fails in shallow clones - Use simple 'git show --name-only HEAD' for maintenance branches - Fix output parsing to properly extract module names - Improve verbose logging to show actual strategy used This approach is much simpler and more reliable: - No dependency on git history depth - Cherry-pick commits contain the files that changed - Works consistently in GitHub Actions environment
1 parent eb1019f commit 007809b

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

.github/scripts/test_discovery.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +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), get files from the commit itself
6666
if branch and branch.endswith('.x'):
67-
# Maintenance branch - cherry-picks are always single commits
68-
# Try HEAD~1..HEAD first, fallback to different strategies if not available
69-
try:
70-
# Test if HEAD~1 exists
71-
subprocess.run(["git", "rev-parse", "HEAD~1"],
72-
cwd=self.repo_root, check=True, capture_output=True)
73-
cmd = ["git", "diff", "--name-only", "HEAD~1..HEAD"]
74-
except subprocess.CalledProcessError:
75-
# HEAD~1 not available (shallow clone), try other approaches
76-
print("HEAD~1 not available, trying alternative approaches", file=sys.stderr)
77-
# Try showing just the files in the current commit
78-
cmd = ["git", "show", "--name-only", "--format=", "HEAD"]
67+
# Maintenance branch - cherry-picks are single commits, just get files in this commit
68+
cmd = ["git", "show", "--name-only", "--format=", "HEAD"]
7969
elif base_ref:
8070
# Explicit base reference provided - use two-dot diff for direct comparison
8171
cmd = ["git", "diff", "--name-only", f"{base_ref}..HEAD"]
@@ -190,7 +180,7 @@ def _detect_default_base(self) -> str:
190180

191181
# Show the actual strategy being used
192182
if branch and branch.endswith('.x'):
193-
return f"HEAD~1 (single commit - maintenance branch {branch})"
183+
return f"git show HEAD (maintenance branch {branch})"
194184
elif pr_base:
195185
return f"origin/{pr_base} (PR base)"
196186
elif branch:

.github/workflows/maintenance-fast.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ jobs:
7676
echo "$MODS"
7777
echo ""
7878
79-
# Extract just the module list (last line that isn't stderr logging)
80-
MODULE_LIST=$(echo "$MODS" | grep -v "^Detected base ref:" | grep -v "^Changed files" | grep -v "^Final module list:" | tail -1)
79+
# Extract just the final result (last line that looks like a module or <none>)
80+
MODULE_LIST=$(echo "$MODS" | grep -E "^(vector-stores|spring-ai|models|<none>|$)" | tail -1)
81+
if [ -z "$MODULE_LIST" ]; then
82+
# If no clear module match, try the very last non-empty line
83+
MODULE_LIST=$(echo "$MODS" | grep -v "^$" | tail -1)
84+
fi
8185
echo "Extracted modules: '$MODULE_LIST'"
8286
echo "modules=$MODULE_LIST" >> "$GITHUB_OUTPUT"
8387

0 commit comments

Comments
 (0)