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

Commit 8930f9f

Browse files
authored
refactor review comment posting (#200)
1 parent b73fb59 commit 8930f9f

File tree

2 files changed

+26
-43
lines changed

2 files changed

+26
-43
lines changed

dist/index.js

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

src/commenter.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,22 @@ ${COMMENT_TAG}`
184184
core.info(
185185
`Creating new review comment for ${comment.path}:${comment.start_line}-${comment.end_line}: ${comment.message}`
186186
)
187+
const commentData: any = {
188+
owner: repo.owner,
189+
repo: repo.repo,
190+
pull_number,
191+
commit_id,
192+
body: comment.message,
193+
path: comment.path,
194+
line: comment.end_line
195+
}
196+
187197
if (comment.start_line !== comment.end_line) {
188-
await octokit.pulls.createReviewComment({
189-
owner: repo.owner,
190-
repo: repo.repo,
191-
pull_number,
192-
commit_id,
193-
body: comment.message,
194-
path: comment.path,
195-
line: comment.end_line,
196-
start_side: 'RIGHT',
197-
start_line: comment.start_line
198-
})
199-
} else {
200-
await octokit.pulls.createReviewComment({
201-
owner: repo.owner,
202-
repo: repo.repo,
203-
pull_number,
204-
commit_id,
205-
body: comment.message,
206-
path: comment.path,
207-
line: comment.end_line
208-
})
198+
commentData.start_side = 'RIGHT'
199+
commentData.start_line = comment.start_line
209200
}
201+
202+
await octokit.pulls.createReviewComment(commentData)
210203
}
211204

212205
commentCounter++

0 commit comments

Comments
 (0)