Skip to content

Commit

Permalink
Report unresolved discussions to the user
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Mount committed Jul 13, 2021
1 parent 647f916 commit 3a70e9d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions marge/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def ensure_mergeable_mr(self, merge_request):
'(have: {0.approver_usernames} missing: {0.approvals_left})'.format(approvals)
)

if not merge_request.blocking_discussions_resolved:
raise CannotMerge("Sorry, I can't merge requests which have unresolved discussions!")

state = merge_request.state
if state not in ('opened', 'reopened', 'locked'):
if state in ('merged', 'closed'):
Expand Down
4 changes: 4 additions & 0 deletions marge/merge_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def approved_by(self):
def web_url(self):
return self.info['web_url']

@property
def blocking_discussions_resolved(self):
return self.info['blocking_discussions_resolved']

@property
def force_remove_source_branch(self):
return self.info['force_remove_source_branch']
Expand Down
1 change: 1 addition & 0 deletions tests/gitlab_api_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, initial_master_sha='505e', gitlab_url=None, fork=False, merge
'force_remove_source_branch': True,
'target_branch': 'master',
'work_in_progress': False,
'blocking_discussions_resolved': True,
'web_url': 'http://git.example.com/group/project/merge_request/666',
}
if merge_request_options is not None:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ def test_ensure_mergeable_mr_wip(self):

assert exc_info.value.reason == "Sorry, I can't merge requests marked as Work-In-Progress!"

def test_ensure_mergeable_mr_unresolved_discussion(self):
merge_job = self.get_merge_job()
merge_request = self._mock_merge_request(
assignee_ids=[merge_job._user.id],
state='opened',
work_in_progress=False,
blocking_discussions_resolved=False,
)
merge_request.fetch_approvals.return_value.sufficient = True
with pytest.raises(CannotMerge) as exc_info:
merge_job.ensure_mergeable_mr(merge_request)

assert exc_info.value.reason == "Sorry, I can't merge requests which have unresolved discussions!"

def test_ensure_mergeable_mr_squash_and_trailers(self):
merge_job = self.get_merge_job(options=MergeJobOptions.default(add_reviewers=True))
merge_request = self._mock_merge_request(
Expand Down

0 comments on commit 3a70e9d

Please sign in to comment.