Skip to content

Commit

Permalink
fix for flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
tclh123 authored and bostik committed Oct 6, 2020
1 parent 5de13be commit 28f4c95
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
20 changes: 13 additions & 7 deletions marge/batch_job.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# pylint: disable=too-many-branches,too-many-statements
# pylint: disable=too-many-branches,too-many-statements,arguments-differ
import logging as log
from time import sleep

from . import git
from . import gitlab
from .commit import Commit
from .job import MergeJob, CannotMerge, SkipMerge
from .merge_request import MergeRequest
Expand Down Expand Up @@ -144,8 +145,9 @@ def update_merge_request(
if sha_now != actual_sha:
raise CannotMerge('Someone pushed to branch while we were trying to merge')

# As we're not using the API to merge the individual MR, we don't strictly need to reapprove it. However,
# it's a little weird to look at the merged MR to find it has no approvals, so let's do it anyway.
# As we're not using the API to merge the individual MR, we don't strictly need to reapprove it.
# However, it's a little weird to look at the merged MR to find it has no approvals,
# so let's do it anyway.
self.maybe_reapprove(merge_request, approvals)
return sha_now

Expand Down Expand Up @@ -241,7 +243,11 @@ def execute(self):
BatchMergeJob.BATCH_BRANCH_NAME,
merge_request.source_branch,
'-m',
'Batch merge !%s into %s (!%s)' % (merge_request.iid, merge_request.target_branch, batch_mr.iid),
'Batch merge !%s into %s (!%s)' % (
merge_request.iid,
merge_request.target_branch,
batch_mr.iid
),
local=True,
)
else:
Expand Down Expand Up @@ -340,6 +346,6 @@ def execute(self):
merge_when_pipeline_succeeds=bool(self._project.only_allow_merge_if_pipeline_succeeds),
)
log.info('batch_mr.accept result: %s', ret)
except gitlab.ApiError as e:
log.exception('Gitlab API Error: %s', e)
raise CannotMerge('Gitlab API Error: %s' % e)
except gitlab.ApiError as err:
log.exception('Gitlab API Error: %s', err)
raise CannotMerge('Gitlab API Error: %s' % err)
10 changes: 8 additions & 2 deletions marge/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,16 @@ def update_from_target_branch_and_push(
target_sha = repo.get_commit_hash('origin/' + target_branch)
if updated_sha == target_sha:
raise CannotMerge('these changes already exist in branch `{}`'.format(target_branch))
final_sha = add_trailers and self.add_trailers(merge_request) or updated_sha
final_sha = self.add_trailers(merge_request) if add_trailers else None
final_sha = final_sha or updated_sha
commits_rewrite_done = True
branch_was_modified = final_sha != initial_mr_sha
self.synchronize_mr_with_local_changes(merge_request, branch_was_modified, source_repo_url, skip_ci=skip_ci)
self.synchronize_mr_with_local_changes(
merge_request,
branch_was_modified,
source_repo_url,
skip_ci=skip_ci,
)
except git.GitError:
# A failure to clean up probably means something is fucked with the git repo
# and likely explains any previous failure, so it will better to just
Expand Down
2 changes: 2 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ max-line-length=110
max-args=10
max-attributes=15
max-public-methods=35
# Maximum number of locals for function / method body
max-locals=25

[REPORTS]
output-format=parseable
Expand Down

0 comments on commit 28f4c95

Please sign in to comment.