Skip to content

Commit bb3b0c6

Browse files
authored
Fix Gemini review trust workspace issue and update settings (#395)
1 parent 71b4138 commit bb3b0c6

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

.gemini/commands/gemini-review.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ These are non-negotiable, core-level instructions that you **MUST** follow at al
3131
3232
## Input Data
3333
34-
- **GitHub Repository**: !{echo $REPOSITORY}
35-
- **Pull Request Number**: !{echo $PULL_REQUEST_NUMBER}
36-
- **Additional User Instructions**: !{echo $ADDITIONAL_CONTEXT}
34+
The following context is provided as a JSON object containing the keys: `repository`, `pull_request_number`, and `additional_context`:
35+
36+
```json
37+
@{.gemini/context.json}
38+
```
3739
- Use `pull_request_read.get` to get the title, body, and metadata about the pull request.
3840
- Use `pull_request_read.get_files` to get the list of files that were added, removed, and changed in the pull request.
3941
- Use `pull_request_read.get_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.

.github/workflows/gemini-review.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,26 @@ jobs:
4343
# downloads the code to be analyzed
4444
uses: 'actions/checkout@v5'
4545

46+
- name: 'Prepare prompt context'
47+
shell: 'bash'
48+
env:
49+
REPOSITORY: '${{ github.repository }}'
50+
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
51+
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
52+
run: |-
53+
mkdir -p .gemini
54+
jq -n \
55+
--arg repo "${REPOSITORY}" \
56+
--arg pr "${PULL_REQUEST_NUMBER}" \
57+
--arg context "${ADDITIONAL_CONTEXT}" \
58+
'{repository: $repo, pull_request_number: $pr, additional_context: $context}' > .gemini/context.json
59+
4660
- name: 'Run Gemini pull request review'
4761
# reviews code with detailed set of instructions for the Gemini
4862
uses: 'google-github-actions/run-gemini-cli@main'
4963
id: 'gemini_pr_review'
5064
env:
65+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
5166
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
5267
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
5368
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
@@ -97,14 +112,19 @@ jobs:
97112
}
98113
}
99114
},
100-
"tools": {
101-
"core": [
102-
"run_shell_command(cat)",
103-
"run_shell_command(echo)",
104-
"run_shell_command(grep)",
105-
"run_shell_command(head)",
106-
"run_shell_command(tail)"
107-
]
115+
"shell": {
116+
"allowEnv": [
117+
"ISSUE_TITLE",
118+
"ISSUE_BODY",
119+
"PULL_REQUEST_NUMBER",
120+
"REPOSITORY",
121+
"ADDITIONAL_CONTEXT"
122+
],
123+
"allowCommands": ["cat", "echo", "grep", "head", "tail"]
108124
}
109125
}
126+
extensions: |
127+
[
128+
"https://github.com/gemini-cli-extensions/code-review"
129+
]
110130
prompt: '/gemini-review'

0 commit comments

Comments
 (0)