Skip to content

Commit 03cd8c0

Browse files
committed
fix(workflow): add step to force rewritten git history in release automation (refs #68)
1 parent 8e67427 commit 03cd8c0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/release-automation.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,42 @@ jobs:
149149
with:
150150
fetch-depth: 0
151151

152+
- name: Force Rewritten History
153+
run: |
154+
echo "=== FORCING REWRITTEN HISTORY ==="
155+
156+
# Force fetch all refs to ensure we have the latest history
157+
git fetch --all --tags --force
158+
159+
# Verify we have the correct history
160+
echo "Current HEAD: $(git rev-parse HEAD)"
161+
echo "Tag v${{ inputs.prev_version }}: $(git rev-parse v${{ inputs.prev_version }})"
162+
163+
# Check if we're using the rewritten history
164+
if git log --oneline v${{ inputs.prev_version }}..HEAD | wc -l | grep -q "397"; then
165+
echo "❌ Still using old history (397 commits detected)"
166+
echo "Attempting to force rewritten history..."
167+
168+
# Try to fetch the rewritten history explicitly
169+
git fetch origin --force
170+
git reset --hard origin/main
171+
git fetch --all --tags --force
172+
173+
# Verify again
174+
COMMIT_COUNT=$(git log --oneline v${{ inputs.prev_version }}..HEAD | wc -l)
175+
echo "Commit count after force fetch: $COMMIT_COUNT"
176+
177+
if [[ $COMMIT_COUNT -gt 200 ]]; then
178+
echo "❌ Still using old history. Manual intervention required."
179+
echo "The repository may need to be re-pushed with the rewritten history."
180+
exit 1
181+
else
182+
echo "✅ Now using rewritten history"
183+
fi
184+
else
185+
echo "✅ Using rewritten history"
186+
fi
187+
152188
- name: Verify Git History
153189
run: |
154190
echo "=== GIT HISTORY VERIFICATION ==="

0 commit comments

Comments
 (0)