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

Only delete source branch if it was forced. #193

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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: 4 additions & 0 deletions marge/merge_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def approved_by(self):
def web_url(self):
return self.info['web_url']

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

def refetch_info(self):
self._info = self._api.call(GET('/projects/{0.project_id}/merge_requests/{0.iid}'.format(self)))

Expand Down
2 changes: 1 addition & 1 deletion marge/single_merge_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def update_merge_request_and_accept(self, approvals):
self.ensure_mergeable_mr(merge_request)

try:
merge_request.accept(remove_branch=True, sha=actual_sha)
merge_request.accept(remove_branch=merge_request.force_remove_source_branch, sha=actual_sha)
except gitlab.NotAcceptable as err:
new_target_sha = Commit.last_on_branch(self._project.id, merge_request.target_branch, api).id
# target_branch has moved under us since we updated, just try again
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ max-line-length=110
[DESIGN]
max-args=10
max-attributes=15
max-public-methods=30
max-public-methods=35

[REPORTS]
output-format=parseable
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 @@ -54,6 +54,7 @@ def __init__(self, initial_master_sha='505e', gitlab_url=None, fork=False, merge
'source_project_id': 1234,
'target_project_id': 1234,
'source_branch': 'useless_new_feature',
'force_remove_source_branch': True,
'target_branch': 'master',
'work_in_progress': False,
'web_url': 'http://git.example.com/group/project/merge_request/666',
Expand Down
1 change: 1 addition & 0 deletions tests/test_merge_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'source_project_id': 5678,
'target_project_id': 1234,
'source_branch': 'useless_new_feature',
'force_remove_source_branch': True,
'target_branch': 'master',
'work_in_progress': False,
}
Expand Down