small updates

convert errors to strings when bot is leaving a comment
comment out a portion of code that was unnecessarily pulling
This commit is contained in:
Moby von Briesen 2023-05-12 01:22:10 -04:00
parent 9678a1c961
commit 157212c5fb
2 changed files with 22 additions and 14 deletions

View File

@ -147,7 +147,7 @@ func (p pullPalRepo) checkIssuesAndComments() error {
if err != nil { if err != nil {
// TODO leave comment if error (make configurable) // TODO leave comment if error (make configurable)
p.log.Error("error handling issue", zap.Error(err)) p.log.Error("error handling issue", zap.Error(err))
commentText := fmt.Sprintf("I ran into a problem working on this:\n```\n%w\n```", err) commentText := fmt.Sprintf("I ran into a problem working on this:\n```\n%s\n```", err.Error())
err = p.ghClient.CommentOnIssue(issue.Number, commentText) err = p.ghClient.CommentOnIssue(issue.Number, commentText)
if err != nil { if err != nil {
p.log.Error("error commenting on issue with error", zap.Error(err)) p.log.Error("error commenting on issue with error", zap.Error(err))
@ -175,7 +175,7 @@ func (p pullPalRepo) checkIssuesAndComments() error {
if err != nil { if err != nil {
// TODO leave comment if error (make configurable) // TODO leave comment if error (make configurable)
p.log.Error("error handling comment", zap.Error(err)) p.log.Error("error handling comment", zap.Error(err))
commentText := fmt.Sprintf("I ran into a problem working on this:\n```\n%w\n```", err) commentText := fmt.Sprintf("I ran into a problem working on this:\n```\n%s\n```", err.Error())
err = p.ghClient.RespondToComment(comment.PRNumber, comment.ID, commentText) err = p.ghClient.RespondToComment(comment.PRNumber, comment.ID, commentText)
if err != nil { if err != nil {
p.log.Error("error commenting on thread with error", zap.Error(err)) p.log.Error("error commenting on thread with error", zap.Error(err))
@ -202,6 +202,7 @@ func (p *pullPalRepo) handleIssue(issue vc.Issue) error {
changeRequest, err := p.localGitClient.ParseIssueAndStartCommit(issue) changeRequest, err := p.localGitClient.ParseIssueAndStartCommit(issue)
if err != nil { if err != nil {
p.log.Error("error parsing issue and starting commit", zap.Error(err))
return err return err
} }

View File

@ -22,6 +22,7 @@ import (
// LocalGitClient represents a service that interacts with a local git repository. // LocalGitClient represents a service that interacts with a local git repository.
type LocalGitClient struct { type LocalGitClient struct {
log *zap.Logger
self Author self Author
repo Repository repo Repository
@ -29,7 +30,7 @@ type LocalGitClient struct {
} }
// NewLocalGitClient initializes a local git client by checking out a repository locally. // NewLocalGitClient initializes a local git client by checking out a repository locally.
func NewLocalGitClient( /*ctx context.Context, */ log *zap.Logger, self Author, repo Repository) (*LocalGitClient, error) { func NewLocalGitClient(log *zap.Logger, self Author, repo Repository) (*LocalGitClient, error) {
log.Info("checking out local github repo", zap.String("repo name", repo.Name), zap.String("local path", repo.LocalPath)) log.Info("checking out local github repo", zap.String("repo name", repo.Name), zap.String("local path", repo.LocalPath))
// clone provided repository to local path // clone provided repository to local path
if repo.LocalPath == "" { if repo.LocalPath == "" {
@ -56,6 +57,7 @@ func NewLocalGitClient( /*ctx context.Context, */ log *zap.Logger, self Author,
repo.localRepo = localRepo repo.localRepo = localRepo
return &LocalGitClient{ return &LocalGitClient{
log: log,
self: self, self: self,
repo: repo, repo: repo,
}, nil }, nil
@ -78,17 +80,19 @@ func (gc *LocalGitClient) CheckoutRemoteBranch(branchName string) (err error) {
} }
// Pull the latest changes from the remote branch // Pull the latest changes from the remote branch
err = gc.worktree.Pull(&git.PullOptions{ /*
RemoteName: "origin", err = gc.worktree.Pull(&git.PullOptions{
Auth: &http.BasicAuth{ RemoteName: "origin",
Username: gc.self.Handle, Auth: &http.BasicAuth{
Password: gc.self.Token, Username: gc.self.Handle,
}, Password: gc.self.Token,
}) },
if err != nil && err != git.NoErrAlreadyUpToDate { Force: true,
return err })
} if err != nil && err != git.NoErrAlreadyUpToDate {
return err
}
*/
return nil return nil
} }
@ -234,11 +238,13 @@ func (gc *LocalGitClient) ParseIssueAndStartCommit(issue Issue) (llm.CodeChangeR
// start a worktree // start a worktree
err := gc.StartCommit() err := gc.StartCommit()
if err != nil { if err != nil {
gc.log.Error("error starting commit", zap.Error(err))
return changeRequest, err return changeRequest, err
} }
err = gc.CheckoutRemoteBranch(issueBody.BaseBranch) err = gc.CheckoutRemoteBranch(issueBody.BaseBranch)
if err != nil { if err != nil {
gc.log.Error("error checking out remote branch", zap.Error(err))
return changeRequest, err return changeRequest, err
} }
@ -247,6 +253,7 @@ func (gc *LocalGitClient) ParseIssueAndStartCommit(issue Issue) (llm.CodeChangeR
for _, path := range issueBody.FilePaths { for _, path := range issueBody.FilePaths {
nextFile, err := gc.GetLocalFile(path) nextFile, err := gc.GetLocalFile(path)
if err != nil { if err != nil {
gc.log.Error("error getting local file", zap.Error(err))
return changeRequest, err return changeRequest, err
} }
files = append(files, nextFile) files = append(files, nextFile)