fix: correct merge detection and branch pattern in stale-release-cleanup
- Use git merge-base --is-ancestor instead of git log --merges --ancestry-path for reliable merge detection (works with squash merges and rebases) - Narrow v* glob to v[0-9]* to avoid matching vendor/ or similar Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@ jobs:
|
|||||||
DAYS=14
|
DAYS=14
|
||||||
|
|
||||||
# Find release branches older than 14 days not on main
|
# Find release branches older than 14 days not on main
|
||||||
for branch in $(git for-each-ref --format '%(refname:short)' 'refs/heads/release/*' 'refs/heads/v*'); do
|
for branch in $(git for-each-ref --format '%(refname:short)' 'refs/heads/release/*' 'refs/heads/v[0-9]*'); do
|
||||||
ts=$(git log -1 --format='%ct' "$branch")
|
ts=$(git log -1 --format='%ct' "$branch")
|
||||||
if [ -z "$ts" ]; then
|
if [ -z "$ts" ]; then
|
||||||
continue
|
continue
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
|
|
||||||
if [ "$age_days" -gt "$DAYS" ]; then
|
if [ "$age_days" -gt "$DAYS" ]; then
|
||||||
# Check if branch has been merged into main
|
# Check if branch has been merged into main
|
||||||
if git log --merges --ancestry-path "$branch..main" --oneline 2>/dev/null | grep -q .; then
|
if git merge-base --is-ancestor "$branch" main 2>/dev/null; then
|
||||||
echo "Merged branch found: $branch (age: ${age_days}d)"
|
echo "Merged branch found: $branch (age: ${age_days}d)"
|
||||||
if [ "$DRY_RUN" != "true" ]; then
|
if [ "$DRY_RUN" != "true" ]; then
|
||||||
echo "Deleting merged branch: $branch"
|
echo "Deleting merged branch: $branch"
|
||||||
@@ -60,4 +60,4 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Release branches found:"
|
echo "Release branches found:"
|
||||||
git for-each-ref --format '%(refname:short) - %(committerdate:relative)' \
|
git for-each-ref --format '%(refname:short) - %(committerdate:relative)' \
|
||||||
'refs/heads/release/*' 'refs/heads/v*' 2>/dev/null || echo "None found"
|
'refs/heads/release/*' 'refs/heads/v[0-9]*' 2>/dev/null || echo "None found"
|
||||||
Reference in New Issue
Block a user