Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marking branch for removal after merge in Gitlab #348

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def __repr__(self):

class GitlabConfig(object):

def __init__(self, should_remove_source_branch=False, merge_when_pipeline_succeeds=False):
self.should_remove_source_branch = should_remove_source_branch
def __init__(self, remove_source_branch=False, merge_when_pipeline_succeeds=False):
self.remove_source_branch = remove_source_branch
self.merge_when_pipeline_succeeds = merge_when_pipeline_succeeds

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions pyup/providers/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def close_pull_request(self, bot_repo, user_repo, pull_request, comment, prefix)
self.delete_branch(user_repo, source_branch, prefix)

def _merge_merge_request(self, mr, config):
mr.merge(should_remove_source_branch=config.gitlab.should_remove_source_branch,
mr.merge(remove_source_branch=config.gitlab.remove_source_branch,
merge_when_pipeline_succeeds=True)

def create_pull_request(self, repo, title, body, base_branch, new_branch, pr_label, assignees, config):
Expand All @@ -184,7 +184,7 @@ def create_pull_request(self, repo, title, body, base_branch, new_branch, pr_lab
'title': title,
'description': body,
'pr_label': pr_label,
'should_remove_source_branch': config.gitlab.should_remove_source_branch
'remove_source_branch': config.gitlab.remove_source_branch
rafaelpivato marked this conversation as resolved.
Show resolved Hide resolved
})

if config.gitlab.merge_when_pipeline_succeeds:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ def test_assignees(self):
def test_gitlab(self):
update = {
"gitlab": {
"should_remove_source_branch": True,
"remove_source_branch": True,
"merge_when_pipeline_succeeds": True
}
}
config = Config()
self.assertEqual(config.gitlab.should_remove_source_branch, False)
self.assertEqual(config.gitlab.remove_source_branch, False)
self.assertEqual(config.gitlab.merge_when_pipeline_succeeds, False)
config.update_config(update)
self.assertEqual(config.gitlab.should_remove_source_branch, True)
self.assertEqual(config.gitlab.remove_source_branch, True)
self.assertEqual(config.gitlab.merge_when_pipeline_succeeds, True)


class GitlabConfigTestCase(TestCase):

def test_repr(self):
config = GitlabConfig(should_remove_source_branch=False)
config = GitlabConfig(remove_source_branch=False)
self.assertEqual(config.__repr__(), str(config.__dict__))


Expand Down
6 changes: 3 additions & 3 deletions tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,16 @@ def test_merge_pull_request(self):
config = Config()
self.provider._merge_merge_request(mr, config)
mr.merge.assert_called_once_with(merge_when_pipeline_succeeds=True,
should_remove_source_branch=False)
remove_source_branch=False)

def test_merge_pull_request_with_remove(self):
mr = Mock()
mr.merge.return_value = True
config = Config()
config.update_config({'gitlab': {'should_remove_source_branch': True}})
config.update_config({'gitlab': {'remove_source_branch': True}})
self.provider._merge_merge_request(mr, config)
mr.merge.assert_called_once_with(merge_when_pipeline_succeeds=True,
should_remove_source_branch=True)
remove_source_branch=True)

def test_create_pull_request_with_exceeding_body(self):
body = ''.join(["a" for i in range(0, 65536 + 1)])
Expand Down