diff --git a/plugins/auto_merge/checks/has_no_open_discussions.go b/plugins/auto_merge/checks/has_no_open_discussions.go index 6f9fa6f..40072c0 100644 --- a/plugins/auto_merge/checks/has_no_open_discussions.go +++ b/plugins/auto_merge/checks/has_no_open_discussions.go @@ -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 { diff --git a/plugins/auto_merge/merge_checks.go b/plugins/auto_merge/merge_checks.go index af1a5b4..94c84ad 100644 --- a/plugins/auto_merge/merge_checks.go +++ b/plugins/auto_merge/merge_checks.go @@ -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,