-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file is null causing fail, if null skipping file #5
Conversation
if file.Patch == nil { | ||
continue | ||
} | ||
|
||
prompt := fmt.Sprintf(oAIClient.PromptDescribeChanges, *file.Patch) | ||
|
||
if len(prompt) > 4096 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code patch looks fine overall. The addition of a check for file.Patch being nil and continuing the loop if true is good to prevent any potential errors. Possible improvements could be to utilize error handling for any potential errors that could occur during the code execution. Additionally, using constants for hard-coded values such as the prompt length limit could improve code readability and maintainability. Overall, there doesn't seem to be any major bug risk.
if file.Patch == nil { | ||
continue | ||
} | ||
|
||
prompt := fmt.Sprintf(oAIClient.PromptReview, *file.Patch) | ||
|
||
if len(prompt) > 4096 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code patch seems to be checking if the file has a patch before prompting for review. This could be helpful in avoiding unnecessary prompts and saving resources. However, without seeing the surrounding code, it's unclear if this is the best way to handle this scenario.
One potential improvement suggestion could be to provide more detailed error messages or debug logging to help diagnose any issues that arise during the run function. Additionally, adding some comments to the code can help make it more understandable to others who may review or work on it in the future.
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" | ||
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" | ||
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" | ||
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" | ||
) | ||
|
||
type Client struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code patch includes changes to the prompts in the import
section, as well as adding a space after the word "review" in the PromptReview
and PromptOverallReview
constants.
As it is a small change, there is not much bug risk involved. However, it is always important to test the changes after they are made to ensure that they do not cause any issues.
As for improvement suggestions, it may be helpful to have clearer prompts for the user to know what is expected of them when reviewing code or generating pull request descriptions. This could potentially save time and confusion in the long run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JC1738 thanks for contribution!
Description
This pull request aims to resolve the issue of file being null causing failure in the system. Changes have been made in
cmd/description/main.go
to include a condition that checks if the file patch is null to prevent errors. If the file patch is not null, then the function prompt will be executed to describe changes in the file. The pull request title and body have also been included in the OverallDescribeCompletion string. Additionally, changes have been made incmd/review/main.go
to fix a bug that previously caused the prompt to exceed the maximum character limit of 4096 and resulted in a crash. The issue where the prompt was still being generated even if the file's patch was null has also been resolved. Changes have been made to clean up the code and ensure that irrelevant files are skipped during the review process. Finally, the code patches foropenai/openai.go
have been updated to modify the PromptReview and PromptOverallReview prompts. The updated prompts now request code reviews in English and welcome any bug risks and improvement suggestions.Changes