Fixed reaction counting bug (i think)
This commit is contained in:
parent
e63bd7fd86
commit
b44f52fe4c
1 changed files with 25 additions and 25 deletions
50
bot/utils.go
50
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue