mirror of
https://github.com/Pull-Pal/pull-pal.git
synced 2024-12-21 17:46:24 -05:00
some changes
make some unnecessary logging debug logs add some randomness into branch name create directories as necessary if they don't exist
This commit is contained in:
parent
157212c5fb
commit
dfef07a1c0
@ -6,7 +6,9 @@ File:
|
||||
```
|
||||
|
||||
Diff:
|
||||
```
|
||||
{{ .Diff }}
|
||||
```
|
||||
|
||||
Comment:
|
||||
{{ .Contents }}
|
||||
@ -14,8 +16,8 @@ Comment:
|
||||
The above is information about a comment left on a file. The diff contains information about the precise location of the comment.
|
||||
|
||||
First, determine if the comment is a question or a request for changes.
|
||||
If the comment is a question, come up with an answer, and respond exactly as outlined directly below "Response Template A"
|
||||
If the comment is a request, modify the file provided at the beginning of the message, and respond exactly as outlined directly below "Response Template B".
|
||||
If the comment is a question, come up with an answer, and respond exactly as outlined directly below "Response Template A", starting with "Q".
|
||||
If the comment is a request, modify the file provided at the beginning of the message, and respond exactly as outlined directly below "Response Template B", starting with "R".
|
||||
|
||||
Response Template A:
|
||||
Q
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@ -56,7 +57,6 @@ func NewPullPal(ctx context.Context, log *zap.Logger, cfg Config) (*PullPal, err
|
||||
openAIClient := llm.NewOpenAIClient(log.Named("openaiClient"), cfg.Model, cfg.OpenAIToken)
|
||||
|
||||
ppRepos := []pullPalRepo{}
|
||||
fmt.Println("asdfasfdasfasdfasdf")
|
||||
for _, r := range cfg.Repos {
|
||||
fmt.Println(r)
|
||||
parts := strings.Split(r, "/")
|
||||
@ -130,7 +130,7 @@ func (p *PullPal) Run() error {
|
||||
|
||||
// checkIssuesAndComments will attempt to find and solve one issue and one comment, and then return.
|
||||
func (p pullPalRepo) checkIssuesAndComments() error {
|
||||
p.log.Info("checking github issues...")
|
||||
p.log.Debug("checking github issues...")
|
||||
issues, err := p.ghClient.ListOpenIssues(p.listIssueOptions)
|
||||
if err != nil {
|
||||
p.log.Error("error listing issues", zap.Error(err))
|
||||
@ -138,7 +138,7 @@ func (p pullPalRepo) checkIssuesAndComments() error {
|
||||
}
|
||||
|
||||
if len(issues) == 0 {
|
||||
p.log.Info("no issues found")
|
||||
p.log.Debug("no issues found")
|
||||
} else {
|
||||
p.log.Info("picked issue to process")
|
||||
|
||||
@ -156,7 +156,7 @@ func (p pullPalRepo) checkIssuesAndComments() error {
|
||||
}
|
||||
}
|
||||
|
||||
p.log.Info("checking pr comments...")
|
||||
p.log.Debug("checking pr comments...")
|
||||
comments, err := p.ghClient.ListOpenComments(vc.ListCommentOptions{
|
||||
Handles: p.listIssueOptions.Handles,
|
||||
})
|
||||
@ -166,7 +166,7 @@ func (p pullPalRepo) checkIssuesAndComments() error {
|
||||
}
|
||||
|
||||
if len(comments) == 0 {
|
||||
p.log.Info("no comments found")
|
||||
p.log.Debug("no comments found")
|
||||
} else {
|
||||
p.log.Info("picked comment to process")
|
||||
|
||||
@ -211,7 +211,8 @@ func (p *pullPalRepo) handleIssue(issue vc.Issue) error {
|
||||
return err
|
||||
}
|
||||
|
||||
newBranchName := fmt.Sprintf("fix-%d", issue.Number)
|
||||
randomNumber := rand.Intn(100) + 1
|
||||
newBranchName := fmt.Sprintf("fix-%d-%d", issue.Number, randomNumber)
|
||||
for _, f := range changeResponse.Files {
|
||||
p.log.Info("replacing or adding file", zap.String("path", f.Path), zap.String("contents", f.Contents))
|
||||
err = p.localGitClient.ReplaceOrAddLocalFile(f)
|
||||
|
@ -191,8 +191,13 @@ func (gc *LocalGitClient) ReplaceOrAddLocalFile(newFile llm.File) error {
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(gc.repo.LocalPath, newFile.Path)
|
||||
dirPath := filepath.Dir(fullPath)
|
||||
err := os.MkdirAll(dirPath, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(fullPath, []byte(newFile.Contents), 0644)
|
||||
err = ioutil.WriteFile(fullPath, []byte(newFile.Contents), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user