mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 22:38:50 +00:00
fix: enhance changelog update logic to prevent infinite loops
- Added checks to skip changelog updates if the only unpushed commit is a changelog update commit. - Improved handling of multiple unpushed commits by excluding the latest changelog commit from the diff analysis. - Cleaned up temporary changelog preview files when no other changes are detected.
This commit is contained in:
parent
3ba7e88e4e
commit
2b51859ea7
@ -108,6 +108,28 @@ UNPUSHED_DIFF=$(git diff "$REMOTE_BRANCH"..HEAD 2>/dev/null || echo "")
|
||||
UNPUSHED_COMMITS=$(git rev-list --count "$REMOTE_BRANCH"..HEAD 2>/dev/null || echo "0")
|
||||
[ -z "$UNPUSHED_COMMITS" ] && UNPUSHED_COMMITS="0"
|
||||
|
||||
# Check if the only unpushed commit is a changelog update commit
|
||||
# If so, exclude it from the diff to avoid infinite loops
|
||||
if [ "$UNPUSHED_COMMITS" -gt 0 ]; then
|
||||
LATEST_COMMIT_MSG=$(git log -1 --pretty=%B HEAD 2>/dev/null || echo "")
|
||||
if echo "$LATEST_COMMIT_MSG" | grep -q "chore: update changelog and version"; then
|
||||
# If the latest commit is a changelog commit, check if there are other commits
|
||||
if [ "$UNPUSHED_COMMITS" -eq 1 ]; then
|
||||
log "Latest commit is a changelog update. No other changes detected. Skipping changelog update."
|
||||
# Clean up any old preview files
|
||||
rm -f "$REPO_ROOT/.changelog_preview.tmp" "$REPO_ROOT/.changelog_version.tmp"
|
||||
exit 0
|
||||
else
|
||||
# Multiple commits, exclude the latest changelog commit from diff
|
||||
log "Multiple unpushed commits detected. Excluding latest changelog commit from analysis."
|
||||
# Get all commits except the latest one
|
||||
UNPUSHED_DIFF=$(git diff "$REMOTE_BRANCH"..HEAD~1 2>/dev/null || echo "")
|
||||
UNPUSHED_COMMITS=$(git rev-list --count "$REMOTE_BRANCH"..HEAD~1 2>/dev/null || echo "0")
|
||||
[ -z "$UNPUSHED_COMMITS" ] && UNPUSHED_COMMITS="0"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Found: $UNSTAGED_COUNT unstaged file(s), $STAGED_COUNT staged file(s), $UNPUSHED_COMMITS unpushed commit(s)"
|
||||
|
||||
# Combine all diffs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user