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

Commit a1729bc

Browse files
authored
single line comments (#411)
<!-- This is an auto-generated comment: release notes by OSS CodeRabbit --> ### Summary by CodeRabbit **Refactor:** - Updated the annotation format in code hunks for better readability. - Introduced a new regular expression to handle single line comments in `src/review.ts`. - Adjusted guidelines for providing comments in code reviews in `src/prompts.ts`. > 🎉 Here's to the code that we refine, > With each little tweak, it shines more divine. > Single line comments, now easier to find, > Making our reviews more streamlined and kind. 🥳 <!-- end of auto-generated comment: release notes by OSS CodeRabbit -->
1 parent 5e10fbe commit a1729bc

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

dist/index.js

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

src/prompts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ The format for changes provided below consists of multiple change
105105
sections, each containing a new hunk (annotated with line numbers),
106106
an old hunk, and optionally, existing comment chains. Note that the
107107
old hunk code has been replaced by the new hunk. The line number
108-
annotation on each line in the new hunk is of the
109-
format \`<line_number><colon><whitespace>\`.
108+
annotation on some lines in the new hunk is of the format
109+
\`<line_number><colon><whitespace>\`.
110110
111111
### Format for changes
112112
@@ -143,7 +143,7 @@ format \`<line_number><colon><whitespace>\`.
143143
strong evidence within the provided context to suggest there might be a problem.
144144
- Do not repeat information that is already evident from the code or the pull
145145
request. Do not include general feedback, summaries, explanations of changes,
146-
compliments for following good practices.
146+
and/or compliments for following good practices.
147147
- Do not question the developer's intention behind the changes or caution them to
148148
ensure that their modifications do not introduce compatibility issues with
149149
other dependencies.

src/review.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ function parseReview(
874874

875875
const lines = response.split('\n')
876876
const lineNumberRangeRegex = /(?:^|\s)(\d+)-(\d+):\s*$/
877+
const lineNumberSingleRegex = /(?:^|\s)(\d+):\s*$/ // New single line regex
877878
const commentSeparator = '---'
878879

879880
let currentStartLine: number | null = null
@@ -976,6 +977,7 @@ ${review.comment}`
976977

977978
for (const line of lines) {
978979
const lineNumberRangeMatch = line.match(lineNumberRangeRegex)
980+
const lineNumberSingleMatch = line.match(lineNumberSingleRegex) // Check for single line match
979981

980982
if (lineNumberRangeMatch != null) {
981983
storeReview()
@@ -986,6 +988,15 @@ ${review.comment}`
986988
info(`Found line number range: ${currentStartLine}-${currentEndLine}`)
987989
}
988990
continue
991+
} else if (lineNumberSingleMatch != null) {
992+
storeReview()
993+
currentStartLine = parseInt(lineNumberSingleMatch[1], 10)
994+
currentEndLine = currentStartLine // For single line comments, start and end are the same
995+
currentComment = ''
996+
if (debug) {
997+
info(`Found single line comment: ${currentStartLine}`)
998+
}
999+
continue
9891000
}
9901001

9911002
if (line.trim() === commentSeparator) {

0 commit comments

Comments
 (0)