From 6e09f164480853a3267a96b2c6a87ba25f49e82b Mon Sep 17 00:00:00 2001 From: "alexey.popov" Date: Tue, 7 May 2019 20:01:02 +0300 Subject: [PATCH 1/2] Fix marking branch for removal after merge in Gitlab According to https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/api/merge_requests.md#L745 --- pyup/config.py | 4 ++-- pyup/providers/gitlab.py | 4 ++-- tests/test_config.py | 8 ++++---- tests/test_gitlab.py | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyup/config.py b/pyup/config.py index 7f760a9..af324da 100644 --- a/pyup/config.py +++ b/pyup/config.py @@ -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): diff --git a/pyup/providers/gitlab.py b/pyup/providers/gitlab.py index bfb3468..4c0f19b 100644 --- a/pyup/providers/gitlab.py +++ b/pyup/providers/gitlab.py @@ -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): @@ -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 }) if config.gitlab.merge_when_pipeline_succeeds: diff --git a/tests/test_config.py b/tests/test_config.py index 9d43d59..55ccae7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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__)) diff --git a/tests/test_gitlab.py b/tests/test_gitlab.py index 5aaa2d5..04263bf 100644 --- a/tests/test_gitlab.py +++ b/tests/test_gitlab.py @@ -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)]) From 15563680ccf939529f8f58fbab2d07fb3f27ec0e Mon Sep 17 00:00:00 2001 From: Rafael Pivato Date: Fri, 1 May 2020 15:05:16 -0300 Subject: [PATCH 2/2] Backward compatible settings --- pyup/config.py | 4 ++-- pyup/providers/gitlab.py | 4 ++-- tests/test_config.py | 8 ++++---- tests/test_gitlab.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyup/config.py b/pyup/config.py index af324da..7f760a9 100644 --- a/pyup/config.py +++ b/pyup/config.py @@ -162,8 +162,8 @@ def __repr__(self): class GitlabConfig(object): - def __init__(self, remove_source_branch=False, merge_when_pipeline_succeeds=False): - self.remove_source_branch = remove_source_branch + def __init__(self, should_remove_source_branch=False, merge_when_pipeline_succeeds=False): + self.should_remove_source_branch = should_remove_source_branch self.merge_when_pipeline_succeeds = merge_when_pipeline_succeeds def __repr__(self): diff --git a/pyup/providers/gitlab.py b/pyup/providers/gitlab.py index 4c0f19b..04ee068 100644 --- a/pyup/providers/gitlab.py +++ b/pyup/providers/gitlab.py @@ -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(remove_source_branch=config.gitlab.remove_source_branch, + mr.merge(remove_source_branch=config.gitlab.should_remove_source_branch, merge_when_pipeline_succeeds=True) def create_pull_request(self, repo, title, body, base_branch, new_branch, pr_label, assignees, config): @@ -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, - 'remove_source_branch': config.gitlab.remove_source_branch + 'remove_source_branch': config.gitlab.should_remove_source_branch }) if config.gitlab.merge_when_pipeline_succeeds: diff --git a/tests/test_config.py b/tests/test_config.py index 55ccae7..9d43d59 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -168,22 +168,22 @@ def test_assignees(self): def test_gitlab(self): update = { "gitlab": { - "remove_source_branch": True, + "should_remove_source_branch": True, "merge_when_pipeline_succeeds": True } } config = Config() - self.assertEqual(config.gitlab.remove_source_branch, False) + self.assertEqual(config.gitlab.should_remove_source_branch, False) self.assertEqual(config.gitlab.merge_when_pipeline_succeeds, False) config.update_config(update) - self.assertEqual(config.gitlab.remove_source_branch, True) + self.assertEqual(config.gitlab.should_remove_source_branch, True) self.assertEqual(config.gitlab.merge_when_pipeline_succeeds, True) class GitlabConfigTestCase(TestCase): def test_repr(self): - config = GitlabConfig(remove_source_branch=False) + config = GitlabConfig(should_remove_source_branch=False) self.assertEqual(config.__repr__(), str(config.__dict__)) diff --git a/tests/test_gitlab.py b/tests/test_gitlab.py index 04263bf..a40bbf3 100644 --- a/tests/test_gitlab.py +++ b/tests/test_gitlab.py @@ -217,7 +217,7 @@ def test_merge_pull_request_with_remove(self): mr = Mock() mr.merge.return_value = True config = Config() - config.update_config({'gitlab': {'remove_source_branch': True}}) + config.update_config({'gitlab': {'should_remove_source_branch': True}}) self.provider._merge_merge_request(mr, config) mr.merge.assert_called_once_with(merge_when_pipeline_succeeds=True, remove_source_branch=True)