Skip to content

Commit 8747e77

Browse files
authored
Merge pull request #16 from ravilushqa/fix_missing_line
fix missing line
2 parents 1422e4a + 1e6a26a commit 8747e77

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cmd/review/review.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ func processFiles(ctx context.Context, openAIClient *oAIClient.Client, diff *git
4040
continue
4141
}
4242

43-
if len(patch) > 3000 {
43+
maxLength := 4096 - len(oAIClient.PromptReview)
44+
if len(patch) > maxLength {
4445
fmt.Println("Patch is too long, truncating")
45-
patch = fmt.Sprintf("%s...", patch[:3000])
46+
patch = fmt.Sprintf("%s...", patch[:maxLength])
4647
}
4748
completion, err := openAIClient.ChatCompletion(ctx, []openai.ChatCompletionMessage{
4849
{
@@ -71,7 +72,10 @@ func processFiles(ctx context.Context, openAIClient *oAIClient.Client, diff *git
7172
fmt.Println("Review is good")
7273
continue
7374
}
74-
for _, issue := range review.Issues {
75+
for i, issue := range review.Issues {
76+
if issue.Line == 0 {
77+
issue.Line = i + 1
78+
}
7579
body := fmt.Sprintf("[%s] %s", issue.Type, issue.Description)
7680
comment := &github.PullRequestComment{
7781
CommitID: diff.Commits[len(diff.Commits)-1].SHA,

openai/openai.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/sashabaranov/go-openai"
99
)
1010

11-
//go:embed assets/review.txt
11+
//go:embed prompt-review.txt
1212
var PromptReview string
1313

1414
const (
File renamed without changes.

0 commit comments

Comments
 (0)