From 22d79a05474235555e6e93e4f4c0f32654e15f66 Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 28 Aug 2023 18:55:49 -0400 Subject: [PATCH 1/2] Revert last commit as it broke it even more --- bot/utils.go | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/bot/utils.go b/bot/utils.go index ab592cc..dc9e2fe 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -115,36 +115,36 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) { for _, comment := range comments { if strings.Contains(comment.GetBody(), "+1") { reactionCount++ - } - } - if reactionCount >= reactionCountGoal { - // Merge the pull request - merge := &github.PullRequestOptions{ - MergeMethod: "merge", // Change this as needed - } + if reactionCount >= reactionCountGoal { + // Merge the pull request + merge := &github.PullRequestOptions{ + MergeMethod: "merge", // Change this as needed + } - _, _, err := client.PullRequests.Merge(ctx, owner, repo, prNumber, "Merging based on reactions", merge) - if err != nil { - log.Println("Error merging pull request:", err) - } else { - log.Println("Pull request merged successfully") - } + _, _, err := client.PullRequests.Merge(ctx, owner, repo, prNumber, "Merging based on reactions", merge) + if err != nil { + log.Println("Error merging pull request:", err) + } else { + log.Println("Pull request merged successfully") + } - return - } else { - commentText := "Current :+1: count is (#{reactionCount}) need (#{reactionRemainingCount}) more to merge" - commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1) - commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1) + return + } else { + commentText := "Current :+1: count is (#{reactionCount}) need (#{reactionRemainingCount}) more to merge" + commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1) + commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1) - // Respond with a comment - comment := &github.IssueComment{ - Body: github.String(commentText), - } + // Respond with a comment + comment := &github.IssueComment{ + Body: github.String(commentText), + } - _, _, err := client.Issues.CreateComment(ctx, owner, repo, prNumber, comment) - if err != nil { - log.Println("Error creating comment:", err) + _, _, err := client.Issues.CreateComment(ctx, owner, repo, prNumber, comment) + if err != nil { + log.Println("Error creating comment:", err) + } + } } } } From 21892a7c662edf028e50fd1d3d4b60a1543e82da Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 28 Aug 2023 18:59:39 -0400 Subject: [PATCH 2/2] Ok let's see what happens --- bot/utils.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/bot/utils.go b/bot/utils.go index dc9e2fe..fd6c690 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -19,23 +19,11 @@ var client = github.NewClient(&http.Client{Transport: itr}) var ctx = context.Background() func initGitHubClient() { - readme, _, err := client.Repositories.GetReadme(ctx, "rowbawts", "theopenestsource", nil) - if err != nil { - fmt.Println(err) - return - } - - content, err := readme.GetContent() - if err != nil { - fmt.Println(err) - return - } - - fmt.Println(content) + log.Println("Initializing......") } func listenForWebhook() { - fmt.Println("Listening on :3333......") + log.Println("Listening on :3333......") http.HandleFunc("/", webhookHandler)