Skip to content

Commit e64c0b1

Browse files
CopilotDRSDavidSoft
andcommitted
Fix git reset logic in auto-merge error handling
Co-authored-by: DRSDavidSoft <[email protected]>
1 parent f2e8ae5 commit e64c0b1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.github/workflows/vendor.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Commit the changes
139139
git add vendor/sources.json
140-
git commit -m "⬆️ Update dependencies ($env:LIST_UPDATED)"
140+
$commitResult = git commit -m "⬆️ Update dependencies ($env:LIST_UPDATED)"
141141
142142
# Push directly to master
143143
git push origin HEAD:master
@@ -159,8 +159,11 @@ jobs:
159159
160160
Write-Warning "Failed to auto-merge: $($_.Exception.Message)"
161161
162-
# Reset changes so PR creation can work
163-
git reset --hard HEAD~1
162+
# Reset only if a commit was made (check if HEAD moved)
163+
$headBeforeReset = git rev-parse HEAD
164+
if ($commitResult) {
165+
git reset --hard HEAD~1
166+
}
164167
165168
# Set flag to create PR instead
166169
echo "AUTO_MERGED=false" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

0 commit comments

Comments
 (0)