Skip to content

fix: stash dirty working tree before batch auto-release (t276)#1119

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t276-auto-release-dirty-tree
Feb 11, 2026
Merged

fix: stash dirty working tree before batch auto-release (t276)#1119
marcusquinn merged 1 commit intomainfrom
bugfix/t276-auto-release-dirty-tree

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 11, 2026

Summary

  • trigger_batch_release() fails when version-manager.sh encounters uncommitted changes (e.g. todo/VERIFY.md from parallel sessions)
  • Stashes dirty working tree before git pull + release, restores after regardless of outcome
  • Graceful fallback: if stash fails, proceeds anyway (release may still fail, but won't lose changes)

Task

t276

Testing

  • bash -n syntax check: pass
  • shellcheck -S warning: no new warnings (only pre-existing SC2034)

Summary by CodeRabbit

  • Chores
    • Enhanced release process stability by improving handling of uncommitted changes and ensuring working state preservation during batch releases.

trigger_batch_release() fails when version-manager.sh encounters
uncommitted changes (e.g. todo/VERIFY.md from parallel sessions).
Stash before pull+release, restore after regardless of outcome.
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where automated batch releases could fail if the Git working directory contained uncommitted changes. It introduces a robust solution to temporarily stash these changes before the release process and restore them afterwards, ensuring the release can proceed smoothly without losing local modifications.

Highlights

  • Pre-release Stashing: Implemented a mechanism to automatically stash any uncommitted local changes before initiating a batch release, preventing version-manager.sh failures caused by a dirty working tree.
  • Post-release Restoration: Ensured that any stashed changes are automatically restored after the batch release process completes, regardless of whether the release succeeded or failed.
  • Stash Failure Handling: Added graceful fallback logic to proceed with the release even if the initial git stash operation fails, logging a warning but not halting the process entirely.
Changelog
  • .agents/scripts/supervisor-helper.sh
    • Added logic to check for a dirty working tree before a batch release.
    • Implemented git stash push to temporarily save local changes.
    • Added git stash pop to restore changes after the release process.
    • Included error handling and logging for git stash operations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 47 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 11 14:03:38 UTC 2026: Code review monitoring started
Wed Feb 11 14:03:39 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 47

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 47
  • VULNERABILITIES: 0

Generated on: Wed Feb 11 14:03:41 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 7d230b3 into main Feb 11, 2026
9 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helpful mechanism to stash a dirty working tree before an auto-release and restore it afterward, preventing release failures on uncommitted changes. The implementation is mostly correct, but there are a few issues related to error handling and adherence to the repository's shell scripting style guide. Specifically, 2>/dev/null is used in several places, which violates the style guide and in one case can hide a critical failure. My review provides suggestions to fix these issues by improving error logging and handling.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The use of || true here swallows the exit code from git stash pop, which means a failure to restore the stashed changes will go unnoticed. This could lead to lost work if the user isn't aware their changes weren't restored. Additionally, using 2>/dev/null violates the repository style guide (rule 50). It's better to handle the error explicitly with a warning message and redirect stderr to the log file.

Suggested change
[[ "$stashed" == "true" ]] && git -C "$repo" stash pop 2>/dev/null || true
[[ "$stashed" == "true" ]] && git -C "$repo" stash pop 2>>"$SUPERVISOR_LOG" || log_warn "Failed to restore stashed changes on pull failure. Manual recovery may be needed."
References
  1. Rule 50 states that 2>/dev/null is acceptable only when redirecting to log files, not for blanket suppression. The code uses 2>/dev/null to suppress stderr without redirecting to a log. (link)

Comment on lines +2256 to +2258
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository style guide (rule 50), 2>/dev/null should only be used when redirecting to a log file. These lines suppress stderr from git status and git stash push, which can hide important error information. To improve observability and adhere to the style guide, please redirect stderr to the $SUPERVISOR_LOG file.

Suggested change
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
if [[ -n "$(git -C "$repo" status --porcelain 2>>"$SUPERVISOR_LOG")" ]]; 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)" &>>"$SUPERVISOR_LOG"; then
References
  1. Rule 50 states that 2>/dev/null is acceptable only when redirecting to log files, not for blanket suppression. The code uses 2>/dev/null to suppress stderr without redirecting to a log. (link)

# 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)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line violates the repository style guide (rule 50) by using 2>/dev/null to suppress stderr. While the error is handled by the || log_warn clause, the style guide is strict about redirecting stderr to a log file for better observability.

Suggested change
git -C "$repo" stash pop 2>/dev/null || log_warn "git stash pop failed (may need manual recovery)"
git -C "$repo" stash pop 2>>"$SUPERVISOR_LOG" || log_warn "git stash pop failed (may need manual recovery)"
References
  1. Rule 50 states that 2>/dev/null is acceptable only when redirecting to log files, not for blanket suppression. The code uses 2>/dev/null to suppress stderr without redirecting to a log. (link)

marcusquinn added a commit that referenced this pull request Feb 11, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

The trigger_batch_release function in .agents/scripts/supervisor-helper.sh now stashes uncommitted changes when the worktree is dirty before performing a release, attempts the release/pull, and restores any created stash (pop) after the release attempt, including on failure paths.

Changes

Cohort / File(s) Summary
Git State Preservation in Release Flow
.agents/scripts/supervisor-helper.sh
Added stash/pop logic around trigger_batch_release: detect dirty worktree, git stash push with timestamped message when needed, set a stashed flag, git stash pop to restore on pull failure or after release completion; adjusted control flow to ensure restoration runs on all exit paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Poem

🌿 Stash the uncommitted, safe and light,
Release proceeds into the night,
If pull should falter, pop restores,
Worktree whole as it was before,
Automation hums — devs sleep tight.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t276-auto-release-dirty-tree

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviews-actioned All review feedback has been actioned

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant