Skip to content

Commit

Permalink
Backward compatible settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelpivato committed May 1, 2020
1 parent 6e09f16 commit 1556368
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
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, 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):
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(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):
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,
'remove_source_branch': config.gitlab.remove_source_branch
'remove_source_branch': config.gitlab.should_remove_source_branch
})

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": {
"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__))


Expand Down
2 changes: 1 addition & 1 deletion tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1556368

Please sign in to comment.