Skip to content

Commit 76855cf

Browse files
authored
Merge pull request #5 from JC1738/file_null
file is null causing fail, if null skipping file
2 parents c487865 + dfde2fd commit 76855cf

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

cmd/description/main.go

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func run(ctx context.Context) error {
5757
var OverallDescribeCompletion string
5858
OverallDescribeCompletion += fmt.Sprintf("Pull request title: %s, body: %s\n\n", pr.GetTitle(), pr.GetBody())
5959
for _, file := range diff.Files {
60+
61+
if file.Patch == nil {
62+
continue
63+
}
64+
6065
prompt := fmt.Sprintf(oAIClient.PromptDescribeChanges, *file.Patch)
6166

6267
if len(prompt) > 4096 {

cmd/review/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ func run(ctx context.Context) error {
6161
continue
6262
}
6363

64+
if file.Patch == nil {
65+
continue
66+
}
67+
6468
prompt := fmt.Sprintf(oAIClient.PromptReview, *file.Patch)
6569

6670
if len(prompt) > 4096 {

openai/openai.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
const (
1111
PromptDescribeChanges = "Bellow is the code patch, Generate a GitHub pull request description based on the following comments without basic prefix\n%s\n"
1212
PromptOverallDescribe = "Bellow comments are generated by AI, Generate a GitHub pull request description based on the following comments without basic prefix in markdown format with ### Description and ### Changes blocks:\n%s\n"
13-
PromptReview = "Bellow is the code patch, please help me do a brief code review,Answer me in English, if any bug risk and improvement suggestion are welcome\n%s\n"
14-
PromptOverallReview = "Bellow comments are generated by AI, please help me do a brief code review,Answer me in English, if any bug risk and improvement suggestion are welcome\n%s\n"
13+
PromptReview = "Bellow is the code patch, please help me do a brief code review, Answer me in English, if any bug risk and improvement suggestion are welcome\n%s\n"
14+
PromptOverallReview = "Bellow comments are generated by AI, please help me do a brief code review, Answer me in English, if any bug risk and improvement suggestion are welcome\n%s\n"
1515
)
1616

1717
type Client struct {

0 commit comments

Comments
 (0)