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

change diff format #132

Merged
merged 20 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,59 +161,62 @@ inputs:
$summary
```

Here is the content of file `$filename` -
Here is the content of file `$filename` with
line numbers -
```
$file_content
```

Format for changes and review comments (if any)
on line ranges (line numbers in new file) -
<start_line-end_line>:
```diff
<diff_hunk>
Format for changes and review comments (if any) -
```new_hunk
<new code with line numbers>
```
```text
<existing review comments>

```old_hunk
<old code>
```
---
<start_line-end_line>:
```diff
<diff_hunk>

```comment_chain
<existing review comments>
```
---
...

The <diff_hunk> is in the unidiff format.

Changes for review -
$patches

Your review must consist of comments in the below format
with a separator between review comments. The format consists of
line ranges and review comments applicable for that line range.
Any other commentary outside of this format will be ignored
line number ranges and review comments applicable for that line
number range. Any other commentary outside of this format will be ignored
and will not be read by the parser -
<review_start_line-review_end_line>:
<start_line_number_in_new_hunk>-<end_line_number_in_new_hunk>:
<your review>
---
...

Make sure <review_start_line> and <review_end_line> for each review
must be within line ranges in the changes above. Don't echo back the
Example:
1-5:
LGTM!
---

It's important that <start_line_number_in_new_hunk> and
<end_line_number_in_new_hunk> for each review must be within
line number ranges of new_hunks. Don't echo back the
code provided to you as the line number range is sufficient to map
your comment to the relevant code section in GitHub. Your responses
will be recorded as multi-line review comments on the GitHub pull
request. Markdown format is preferred for text and fenced
code blocks should be used for code snippets.
your comment to the relevant code section (within new_hunks)
in GitHub. Your responses will be recorded as multi-line review
comments on the GitHub pull request. Markdown format is preferred
for text and fenced code blocks should be used for code snippets.

Provide thorough and thoughtful feedback to identify any
bug risks or provide improvement suggestions in these diff hunks.
Reflect on the provided code at least 3 times and identify any
bug risks or provide improvement suggestions in these changes.
You will point out potential issues such as security, logic errors,
syntax errors, out of bound errors, data races, consistency,
complexity, error handling, typos, grammar, maintainability,
performance, and so on.

If there are no issues or suggestions and the diff hunk is acceptable
If there are no issues or suggestions and the change is acceptable
as-is, please include "LGTM!" (exact word) in your short
review comment.

Expand Down
104 changes: 84 additions & 20 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions src/commenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ${tag}`

if (!found) {
core.info(
`Creating new review comment for ${path}:${end_line}: ${message}`
`Creating new review comment for ${path}:${start_line}-${end_line}: ${message}`
)
await octokit.pulls.createReviewComment({
owner: repo.owner,
Expand All @@ -186,7 +186,9 @@ ${tag}`
})
}
} catch (e) {
core.warning(`Failed to post review comment: ${e}`)
core.warning(
`Failed to post review comment, for ${path}:${start_line}-${end_line}: ${e}`
)
}
}

Expand Down Expand Up @@ -253,9 +255,11 @@ ${COMMENT_REPLY_TAG}
return comments.filter(
(comment: any) =>
comment.path === path &&
comment.start_line === start_line &&
comment.line === end_line &&
comment.body !== ''
comment.body !== '' &&
((comment.start_line &&
comment.start_line >= start_line &&
comment.line <= end_line) ||
comment.line === end_line)
)
}

Expand Down
Loading