-
Notifications
You must be signed in to change notification settings - Fork 11
fix: stash dirty working tree before batch auto-release (t276) #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2249,11 +2249,25 @@ trigger_batch_release() { | |||||
| } | ||||||
| fi | ||||||
|
|
||||||
| # t276: Stash any dirty working tree before release. | ||||||
| # Common cause: todo/VERIFY.md, untracked files from parallel sessions. | ||||||
| # version-manager.sh refuses to release with uncommitted changes. | ||||||
| local stashed=false | ||||||
| if [[ -n "$(git -C "$repo" status --porcelain 2>/dev/null)" ]]; then | ||||||
| log_info "Stashing dirty working tree before release..." | ||||||
| if git -C "$repo" stash push -m "auto-release-stash-$(date +%Y%m%d%H%M%S)" 2>/dev/null; then | ||||||
| stashed=true | ||||||
| else | ||||||
| log_warn "git stash failed, proceeding anyway (release may fail)" | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| # Pull latest (all batch PRs should be merged by now) | ||||||
| git -C "$repo" pull --ff-only origin main 2>/dev/null || { | ||||||
| log_warn "Fast-forward pull failed, trying rebase..." | ||||||
| git -C "$repo" pull --rebase origin main 2>/dev/null || { | ||||||
| log_error "Failed to pull latest main for release" | ||||||
| [[ "$stashed" == "true" ]] && git -C "$repo" stash pop 2>/dev/null || true | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of
Suggested change
References
|
||||||
| return 1 | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -2264,6 +2278,12 @@ trigger_batch_release() { | |||||
| local release_exit=0 | ||||||
| release_output=$(cd "$repo" && bash "$version_manager" release "$release_type" --skip-preflight --force 2>&1) || release_exit=$? | ||||||
|
|
||||||
| # t276: Restore stashed changes after release (regardless of success/failure) | ||||||
| if [[ "$stashed" == "true" ]]; then | ||||||
| log_info "Restoring stashed working tree..." | ||||||
| git -C "$repo" stash pop 2>/dev/null || log_warn "git stash pop failed (may need manual recovery)" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line violates the repository style guide (rule 50) by using
Suggested change
References
|
||||||
| fi | ||||||
|
|
||||||
| echo "$release_output" > "$release_log" 2>/dev/null || true | ||||||
|
|
||||||
| if [[ "$release_exit" -ne 0 ]]; then | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository style guide (rule 50),
2>/dev/nullshould only be used when redirecting to a log file. These lines suppress stderr fromgit statusandgit stash push, which can hide important error information. To improve observability and adhere to the style guide, please redirect stderr to the$SUPERVISOR_LOGfile.References
2>/dev/nullis acceptable only when redirecting to log files, not for blanket suppression. The code uses2>/dev/nullto suppress stderr without redirecting to a log. (link)