test commit
This commit is contained in:
parent
ce7a9b9dae
commit
b681dcbc58
2 changed files with 21 additions and 13 deletions
0
bot/test
Normal file
0
bot/test
Normal file
14
bot/utils.go
14
bot/utils.go
|
@ -90,31 +90,39 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
|||
owner := event.GetRepo().GetOwner().GetLogin()
|
||||
repo := event.GetRepo().GetName()
|
||||
prNumber := event.GetIssue().GetNumber()
|
||||
reactionCount := 0
|
||||
|
||||
if event.GetIssue().IsPullRequest() {
|
||||
reactions, _, err := client.Reactions.ListIssueCommentReactions(ctx, owner, repo, event.GetComment().GetID(), nil)
|
||||
comments, _, err := client.PullRequests.ListComments(ctx, owner, repo, prNumber, nil)
|
||||
if err != nil {
|
||||
log.Println("Error fetching reactions:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if there are thumbs up (:+1:) reactions
|
||||
for _, reaction := range reactions {
|
||||
if *reaction.Content == "+1" {
|
||||
for _, comment := range comments {
|
||||
if *comment.Body == "+1" {
|
||||
reactionCount++
|
||||
|
||||
if reactionCount >= 1 {
|
||||
// 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")
|
||||
}
|
||||
|
||||
reactionCount = 0
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func processPullRequestEvent(event *github.PullRequestEvent) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue