Skip to content

fix(github): detect committed changes in branchIsDirty#12568

Closed
code-yeongyu wants to merge 1 commit into
anomalyco:devfrom
code-yeongyu:fix/github-action-branchisdirty-1417
Closed

fix(github): detect committed changes in branchIsDirty#12568
code-yeongyu wants to merge 1 commit into
anomalyco:devfrom
code-yeongyu:fix/github-action-branchisdirty-1417

Conversation

@code-yeongyu

Copy link
Copy Markdown
Contributor

Summary

The GitHub Action's branchIsDirty() in github/index.ts only checked git status --porcelain, which returns empty when the AI agent has already committed changes via git commit. This caused the push step to be skipped entirely, losing the commit.

Root Cause

When the AI agent commits changes during a /oc command, the working tree becomes clean (git status --porcelain returns nothing). The old branchIsDirty() incorrectly reported false, 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):

  • Capture HEAD before AI chat begins (git rev-parse HEAD)
  • Compare HEAD after chat to detect new commits (even if working tree is clean)
  • Pass uncommittedChanges flag to push functions so they conditionally run git add . && git commit only when needed
  • Always push when dirty=true, regardless of whether changes are committed or not

This 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:

  1. ✅ Uncommitted changes (existing behavior)
  2. ✅ Already-committed changes (new behavior — was broken)

Fixes #1417

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
@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@code-yeongyu code-yeongyu closed this by deleting the head repository Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Integration is not pushing changes in PRs

1 participant