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
34
bot/utils.go
34
bot/utils.go
|
@ -90,28 +90,36 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
||||||
owner := event.GetRepo().GetOwner().GetLogin()
|
owner := event.GetRepo().GetOwner().GetLogin()
|
||||||
repo := event.GetRepo().GetName()
|
repo := event.GetRepo().GetName()
|
||||||
prNumber := event.GetIssue().GetNumber()
|
prNumber := event.GetIssue().GetNumber()
|
||||||
|
reactionCount := 0
|
||||||
|
|
||||||
if event.GetIssue().IsPullRequest() {
|
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 {
|
if err != nil {
|
||||||
log.Println("Error fetching reactions:", err)
|
log.Println("Error fetching reactions:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are thumbs up (:+1:) reactions
|
// Check if there are thumbs up (:+1:) reactions
|
||||||
for _, reaction := range reactions {
|
for _, comment := range comments {
|
||||||
if *reaction.Content == "+1" {
|
if *comment.Body == "+1" {
|
||||||
// Merge the pull request
|
reactionCount++
|
||||||
merge := &github.PullRequestOptions{
|
|
||||||
MergeMethod: "merge", // Change this as needed
|
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
|
||||||
}
|
}
|
||||||
_, _, 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue