Skip to content

Commit

Permalink
fix: Standardize error messages in PullRequestHandler and clean up We…
Browse files Browse the repository at this point in the history
…bhookController
  • Loading branch information
puneeth072003 committed Feb 5, 2025
1 parent 6d8826b commit aa45627
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/github/controllers/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func PullRequestHandler(c *gin.Context) error {
prDescription, err := gh.FetchPullRequestDescription(repoOwner, repoName, pullRequestNumber)
if err != nil {
log.Printf("Unable to fetch pull request description: %v", err)
return fmt.Errorf("Unable to fetch pull request description")
return fmt.Errorf("unable to fetch pull request description")
}

dependencies, context := utils.ParsePRDescription(prDescription)

changedFiles, err := gh.FetchPullRequestFiles(repoOwner, repoName, pullRequestNumber)
if err != nil {
log.Printf("Unable to fetch changed files: %v", err)
return fmt.Errorf("Unable to fetch changed files")
return fmt.Errorf("unable to fetch changed files")
}

fileChan := resolvers.GetFileContents(changedFiles, repoOwner, repoName, commitSHA)
Expand All @@ -68,19 +68,19 @@ func PullRequestHandler(c *gin.Context) error {
generatedTests, err := handlers.GetGeneratedTestsFromGenAI(&payload)
if err != nil {
log.Printf("Error sending payload to GenAI Service: %v", err)
return fmt.Errorf("Error forwarding payload to GenAI Service")
return fmt.Errorf("error forwarding payload to GenAI Service")
}

token, err := token.GetInstance().GetToken()
if err != nil {
log.Printf("Error getting token: %v", err)
return fmt.Errorf("Error getting token")
return fmt.Errorf("error getting token")
}

err = resolvers.PushNewBranchWithTests(token, repoOwner, repoName, generatedTests)
if err != nil {
log.Printf("Error finalizing: %v", err)
return fmt.Errorf("Error finalizing")
return fmt.Errorf("error finalizing")
}

c.JSON(http.StatusAccepted, gin.H{"message": "Pull request has been raised"})
Expand Down
1 change: 0 additions & 1 deletion src/github/controllers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ func WebhookController(ctx *gin.Context) {
}

ctx.Status(http.StatusNoContent)
return
}
4 changes: 2 additions & 2 deletions src/github/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/codesourcerer-bot/github
go 1.23.1

require (
github.com/codesourcerer-bot/proto v0.0.0
github.com/gin-gonic/gin v1.10.0
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/google/go-github/v52 v52.0.0
golang.org/x/oauth2 v0.24.0
gopkg.in/yaml.v3 v3.0.1
google.golang.org/grpc v1.69.2
github.com/codesourcerer-bot/proto v0.0.0
gopkg.in/yaml.v3 v3.0.1
)

replace github.com/codesourcerer-bot/proto => ../common
Expand Down

0 comments on commit aa45627

Please sign in to comment.