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 5 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
38 changes: 24 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,30 +161,37 @@ 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) -

old_hunk:
```
<old code with line numbers>
```
new_hunk:
```
<new code with line numbers>
```
```text
<existing review comments>
```
---
<start_line-end_line>:
```diff
<diff_hunk>
old_hunk:
```
<old code with line numbers>
```
new_hunk:
```
<new code with line numbers>
```
---
...

The <diff_hunk> is in the unidiff format.

Changes for review -
$patches

Expand All @@ -193,13 +200,16 @@ inputs:
line ranges and review comments applicable for that line 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_new_code>-<end_line_number_new_code>:
<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
It's important that <start_line_number_new_code> and
<end_line_number_new_code> for each review must be within
line ranges of new_hunks as you cannot make comments
on line numbers of old_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
Expand Down
103 changes: 88 additions & 15 deletions dist/index.js

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

10 changes: 6 additions & 4 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,8 +255,8 @@ ${COMMENT_REPLY_TAG}
return comments.filter(
(comment: any) =>
comment.path === path &&
comment.start_line === start_line &&
comment.line === end_line &&
comment.start_line >= start_line &&
comment.line <= end_line &&
comment.body !== ''
)
}
Expand Down
Loading