Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 6f25501

Browse files
authored
change diff format (#132)
1 parent 2112860 commit 6f25501

File tree

4 files changed

+211
-67
lines changed

4 files changed

+211
-67
lines changed

action.yml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -161,61 +161,63 @@ inputs:
161161
$summary
162162
```
163163
164-
Here is the content of file `$filename` -
164+
Here is the content of file `$filename` with
165+
line numbers -
165166
```
166167
$file_content
167168
```
168169
169-
Format for changes and review comments (if any)
170-
on line ranges (line numbers in new file) -
171-
<start_line-end_line>:
172-
```diff
173-
<diff_hunk>
170+
Format for changes and review comments (if any) -
171+
```new_hunk
172+
<new code with line numbers>
174173
```
175-
```text
176-
<existing review comments>
174+
175+
```old_hunk
176+
<old code>
177177
```
178-
---
179-
<start_line-end_line>:
180-
```diff
181-
<diff_hunk>
178+
179+
```comment_chain
180+
<existing review comments>
182181
```
183182
---
184183
...
185184
186-
The <diff_hunk> is in the unidiff format.
187-
188185
Changes for review -
189186
$patches
190187
191188
Your review must consist of comments in the below format
192189
with a separator between review comments. The format consists of
193-
line ranges and review comments applicable for that line range.
194-
Any other commentary outside of this format will be ignored
190+
line number ranges and review comments applicable for that line
191+
number range. Any other commentary outside of this format will be ignored
195192
and will not be read by the parser -
196-
<review_start_line-review_end_line>:
193+
<start_line_number_in_new_hunk>-<end_line_number_in_new_hunk>:
197194
<your review>
198195
---
199196
...
200197
201-
Make sure <review_start_line> and <review_end_line> for each review
202-
must be within line ranges in the changes above. Don't echo back the
198+
Example:
199+
1-5:
200+
LGTM!
201+
---
202+
203+
It's important that <start_line_number_in_new_hunk> and
204+
<end_line_number_in_new_hunk> for each review must be within
205+
line number ranges of new_hunks. Don't echo back the
203206
code provided to you as the line number range is sufficient to map
204-
your comment to the relevant code section in GitHub. Your responses
205-
will be recorded as multi-line review comments on the GitHub pull
206-
request. Markdown format is preferred for text and fenced
207-
code blocks should be used for code snippets.
207+
your comment to the relevant code section (within new_hunks)
208+
in GitHub. Your responses will be recorded as multi-line review
209+
comments on the GitHub pull request. Markdown format is preferred
210+
for text and fenced code blocks should be used for code snippets.
208211
209-
Provide thorough and thoughtful feedback to identify any
210-
bug risks or provide improvement suggestions in these diff hunks.
212+
Reflect on the provided code at least 3 times and identify any
213+
bug risks or provide improvement suggestions in these changes.
211214
You will point out potential issues such as security, logic errors,
212215
syntax errors, out of bound errors, data races, consistency,
213216
complexity, error handling, typos, grammar, maintainability,
214217
performance, and so on.
215218
216-
If there are no issues or suggestions and the diff hunk is acceptable
217-
as-is, please include "LGTM!" (exact word) in your short
218-
review comment.
219+
If there are no issues or suggestions and the change is acceptable
220+
as-is, you must include the word `LGTM!` and make a short review comment.
219221
220222
comment:
221223
required: false

dist/index.js

Lines changed: 82 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commenter.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ${tag}`
171171

172172
if (!found) {
173173
core.info(
174-
`Creating new review comment for ${path}:${end_line}: ${message}`
174+
`Creating new review comment for ${path}:${start_line}-${end_line}: ${message}`
175175
)
176176
await octokit.pulls.createReviewComment({
177177
owner: repo.owner,
@@ -186,7 +186,9 @@ ${tag}`
186186
})
187187
}
188188
} catch (e) {
189-
core.warning(`Failed to post review comment: ${e}`)
189+
core.warning(
190+
`Failed to post review comment, for ${path}:${start_line}-${end_line}: ${e}`
191+
)
190192
}
191193
}
192194

@@ -253,9 +255,11 @@ ${COMMENT_REPLY_TAG}
253255
return comments.filter(
254256
(comment: any) =>
255257
comment.path === path &&
256-
comment.start_line === start_line &&
257-
comment.line === end_line &&
258-
comment.body !== ''
258+
comment.body !== '' &&
259+
((comment.start_line &&
260+
comment.start_line >= start_line &&
261+
comment.line <= end_line) ||
262+
comment.line === end_line)
259263
)
260264
}
261265

0 commit comments

Comments
 (0)