mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-17 05:20:23 -07:00
fix(ci): capture agent's true base SHA to prevent patch conflicts
The reasoning job now captures the HEAD commit SHA prior to patch generation (`patch_base_sha`) and passes it to the publish job. The publish job then checks out this precise SHA rather than the original `target_sha`. This ensures that if the agent checks out an existing PR branch to resolve comments, the generated patch is applied cleanly against the tip of that branch instead of causing a merge conflict with main.
This commit is contained in:
@@ -62,6 +62,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
sha: ${{ steps.get_sha.outputs.sha }}
|
sha: ${{ steps.get_sha.outputs.sha }}
|
||||||
target_sha: ${{ steps.get_target_sha.outputs.sha }}
|
target_sha: ${{ steps.get_target_sha.outputs.sha }}
|
||||||
|
patch_base_sha: ${{ steps.generate_patch.outputs.patch_base_sha }}
|
||||||
env:
|
env:
|
||||||
GEMINI_CLI_TRUST_WORKSPACE: 'true'
|
GEMINI_CLI_TRUST_WORKSPACE: 'true'
|
||||||
steps:
|
steps:
|
||||||
@@ -256,6 +257,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 'Generate Patch'
|
- name: 'Generate Patch'
|
||||||
|
id: 'generate_patch'
|
||||||
if: "${{ github.event.inputs.enable_prs == 'true' || github.event_name == 'issue_comment' || github.event.inputs.run_interactive == 'true' }}"
|
if: "${{ github.event.inputs.enable_prs == 'true' || github.event_name == 'issue_comment' || github.event.inputs.run_interactive == 'true' }}"
|
||||||
working-directory: repo-target
|
working-directory: repo-target
|
||||||
run: |
|
run: |
|
||||||
@@ -265,6 +267,7 @@ jobs:
|
|||||||
touch branch-name.txt
|
touch branch-name.txt
|
||||||
touch issue-comment.md
|
touch issue-comment.md
|
||||||
touch pr-comment.md
|
touch pr-comment.md
|
||||||
|
echo "patch_base_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||||
if [ -f critique_result.txt ] && grep -q "\[APPROVED\]" critique_result.txt && ! grep -q "\[REJECTED\]" critique_result.txt; then
|
if [ -f critique_result.txt ] && grep -q "\[APPROVED\]" critique_result.txt && ! grep -q "\[REJECTED\]" critique_result.txt; then
|
||||||
git diff --staged > bot-changes.patch
|
git diff --staged > bot-changes.patch
|
||||||
else
|
else
|
||||||
@@ -322,7 +325,7 @@ jobs:
|
|||||||
- name: 'Checkout'
|
- name: 'Checkout'
|
||||||
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
ref: '${{ needs.reasoning.outputs.target_sha }}'
|
ref: '${{ needs.reasoning.outputs.patch_base_sha || needs.reasoning.outputs.target_sha }}'
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user