fix(github): detect committed changes in branchIsDirty#12568
Closed
code-yeongyu wants to merge 1 commit into
Closed
fix(github): detect committed changes in branchIsDirty#12568code-yeongyu wants to merge 1 commit into
code-yeongyu wants to merge 1 commit into
Conversation
The GitHub Action's branchIsDirty() only checked `git status --porcelain`, which returns empty when the AI agent has already committed changes. This caused the push step to be skipped, losing the commit. Port the fix from the CLI version (packages/opencode/src/cli/cmd/github.ts) to the GitHub Action version (github/index.ts): - Capture HEAD before AI chat begins - Compare HEAD after chat to detect new commits - Pass uncommittedChanges flag to push functions to conditionally run git add/commit Fixes #1417
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The GitHub Action's
branchIsDirty()ingithub/index.tsonly checkedgit status --porcelain, which returns empty when the AI agent has already committed changes viagit commit. This caused the push step to be skipped entirely, losing the commit.Root Cause
When the AI agent commits changes during a
/occommand, the working tree becomes clean (git status --porcelainreturns nothing). The oldbranchIsDirty()incorrectly reportedfalse, so the push was never executed.Fix
Ported the fix from the CLI version (
packages/opencode/src/cli/cmd/github.ts) to the GitHub Action version (github/index.ts):HEADbefore AI chat begins (git rev-parse HEAD)HEADafter chat to detect new commits (even if working tree is clean)uncommittedChangesflag to push functions so they conditionally rungit add . && git commitonly when neededdirty=true, regardless of whether changes are committed or notThis matches the behavior already implemented in the CLI version.
Testing
The fix is a direct port of the working CLI implementation. The three push paths (local PR, fork PR, issue→new branch) all now correctly handle:
Fixes #1417