Skip to content

Commit

Permalink
fix: use notes endpoint to check for unresolved discussions (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashass authored Sep 14, 2023
1 parent 059a904 commit af1949d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions plugins/auto_merge/checks/has_no_open_discussions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ package checks

import (
"github.com/GEPROG/lassie-bot-dog/plugins/auto_merge/config"
"github.com/GEPROG/lassie-bot-dog/utils"
"github.com/xanzy/go-gitlab"
)

type HasNoOpenDiscussionsCheck struct {
Client *gitlab.Client
}

func (check HasNoOpenDiscussionsCheck) Check(_ *config.AutoMergeConfig, _ *gitlab.Project, mergeRequest *gitlab.MergeRequest) bool {
return mergeRequest.BlockingDiscussionsResolved
func (check HasNoOpenDiscussionsCheck) Check(_ *config.AutoMergeConfig, project *gitlab.Project, mergeRequest *gitlab.MergeRequest) bool {
log := utils.Logger(project, mergeRequest)
notes, _, err := check.Client.Notes.ListMergeRequestNotes(mergeRequest.ProjectID, mergeRequest.IID, nil)
if err != nil {
log.Error("Can't load merge-request notes", err)
return false
}
for _, note := range notes {
if note.Resolvable && !note.Resolved {
log.Debug("Found unresolved discussion", note.ID)
return false
}
}
return true
}

func (check HasNoOpenDiscussionsCheck) Name() string {
Expand Down
2 changes: 1 addition & 1 deletion plugins/auto_merge/merge_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (plugin AutoMergePlugin) setupMergeChecks() {
},
checks.HasRequiredLabelsCheck{},
checks.HasNoConflictsCheck{},
checks.HasNoOpenDiscussionsCheck{},
checks.HasNoOpenDiscussionsCheck{Client: plugin.Client},
checks.IsNotWorkInProgressCheck{},
checks.PassesCICheck{
Client: plugin.Client,
Expand Down

0 comments on commit af1949d

Please sign in to comment.