Skip to content

Commit af8357d

Browse files
authored
Add Context in review prompt (#104)
Example: google-gemini/logo-maker#43 (review) google-gemini/logo-maker#61 (review) --------- Signed-off-by: Xuejie(Alicia) Tang <tangxuejie96@163.com>
1 parent 8ea108e commit af8357d

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/gemini-pr-review.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ jobs:
219219
3. Run: echo "${PR_NUMBER}" to get the PR number
220220
4. Run: echo "${ADDITIONAL_INSTRUCTIONS}" to see any specific review
221221
instructions from the user
222-
5. Run: gh pr diff "${PR_NUMBER}" to see the full diff
222+
5. Run: gh pr diff "${PR_NUMBER}" to see the full diff and reference
223+
Context section to understand it
223224
6. For any specific files, use: cat filename, head -50 filename, or
224225
tail -50 filename
225226
7. If ADDITIONAL_INSTRUCTIONS contains text, prioritize those
@@ -346,6 +347,40 @@ jobs:
346347
Keep comments bodies concise and to the point.
347348
Keep each comment focused on one issue.
348349
350+
## Context
351+
The files that are changed in this pull request are represented below in the following
352+
format, showing the file name and the portions of the file that are changed:
353+
354+
<PATCHES>
355+
FILE:<NAME OF FIRST FILE>
356+
DIFF:
357+
<PATCH IN UNIFIED DIFF FORMAT>
358+
359+
--------------------
360+
361+
FILE:<NAME OF SECOND FILE>
362+
DIFF:
363+
<PATCH IN UNIFIED DIFF FORMAT>
364+
365+
--------------------
366+
367+
(and so on for all files changed)
368+
</PATCHES>
369+
370+
Note that if you want to make a comment on the LEFT side of the UI / before the diff code version
371+
to note those line numbers and the corresponding code. Same for a comment on the RIGHT side
372+
of the UI / after the diff code version to note the line numbers and corresponding code.
373+
This should be your guide to picking line numbers, and also very importantly, restrict
374+
your comments to be only within this line range for these files, whether on LEFT or RIGHT.
375+
If you comment out of bounds, the review will fail, so you must pay attention the file name,
376+
line numbers, and pre/post diff versions when crafting your comment.
377+
378+
Here are the patches that were implemented in the pull request, per the
379+
formatting above:
380+
381+
The get the files changed in this pull request, run:
382+
"$(gh pr diff "${PR_NUMBER}" --patch)" to get the list of changed files PATCH
383+
349384
## Review
350385
351386
Once you have the information, provide a comprehensive code review by:
@@ -403,6 +438,7 @@ jobs:
403438
- Highlight positive aspects of the implementation
404439
- Note any recurring themes across files
405440
441+
406442
- name: 'Post PR review failure comment'
407443
if: |-
408444
${{ failure() && steps.gemini_pr_review.outcome == 'failure' }}

0 commit comments

Comments
 (0)