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

single line comments #134

Merged
merged 2 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 27 additions & 12 deletions dist/index.js

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

38 changes: 26 additions & 12 deletions src/commenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,31 @@ ${tag}`
core.info(
`Creating new review comment for ${path}:${start_line}-${end_line}: ${message}`
)
await octokit.pulls.createReviewComment({
owner: repo.owner,
repo: repo.repo,
pull_number,
body: message,
commit_id,
path,
line: end_line,
start_line,
start_side: 'RIGHT'
})
// if start_line is same as end_line, it's a single line comment
// otherwise it's a multi-line comment
if (start_line === end_line) {
await octokit.pulls.createReviewComment({
owner: repo.owner,
repo: repo.repo,
pull_number,
body: message,
commit_id,
path,
line: end_line
})
} else {
await octokit.pulls.createReviewComment({
owner: repo.owner,
repo: repo.repo,
pull_number,
body: message,
commit_id,
path,
line: end_line,
start_line,
start_side: 'RIGHT'
})
}
}
} catch (e) {
core.warning(
Expand Down Expand Up @@ -256,7 +270,7 @@ ${COMMENT_REPLY_TAG}
(comment: any) =>
comment.path === path &&
comment.body !== '' &&
((comment.start_line &&
((comment.start_line !== undefined &&
comment.start_line >= start_line &&
comment.line <= end_line) ||
comment.line === end_line)
Expand Down