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

Optimistic batching for batch merging #252

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

deibido
Copy link

@deibido deibido commented Apr 3, 2020

Fix for issue #164.

Previously we added trailers to each MR and
merged the constituent MRs of a batch MR to
the target branch.
Now we will now optimistically add the trailers
to each MR and rebase on the batch branch. And
when the batch branch passes CI we merge it
which will automatically merge each constituent
branch.

Fix for issue smarkets#164.

Previously we added trailers to each MR and
merged the constituent MRs of a batch MR to
the target branch.
Now we will now optimistically add the trailers
to each MR and rebase on the batch branch. And
when the batch branch passes CI we merge it
which will automatically merge each constituent
branch.
@@ -225,36 +215,34 @@ def execute(self):
working_merge_requests.append(merge_request)
if len(working_merge_requests) <= 1:
raise CannotBatch('not enough ready merge requests')
if self._project.only_allow_merge_if_pipeline_succeeds:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have lost this check. Whilst batching is a bit weird if you don't have pipelines enabled, we'd still want to support simply merging the batch branch in without waiting for any pipelines (which won't exist now) to finish.

@@ -207,6 +194,9 @@ def execute(self):
local=True,
)

# Ensure that individual branch commit SHA matches matches that of its equivalent in batch MR
self.push_force_to_mr(merge_request, True, source_repo_url, skip_ci=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we want to push here - the source branch for the MR will now contain commits of other MRs that have previously been added to the batch branch - we don't want to mess with the original MRs here, especially as the batch can fail.

for merge_request in working_merge_requests:
try:
# FIXME: this should probably be part of the merge request
_, source_repo_url, merge_request_remote = self.fetch_source_project(merge_request)
self.ensure_mr_not_changed(merge_request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this check been lost?

@@ -198,6 +182,9 @@ def execute(self):
merge_request.source_branch,
'%s/%s' % (merge_request_remote, merge_request.source_branch),
)
# Apply the trailers before running the batch MR
self.add_trailers(merge_request)
self.push_force_to_mr(merge_request, True, source_repo_url, skip_ci=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to specify keyword args for the boolean, as makes it easier to know what this is doing (i.e. branch_was_modified=True)

marge/git.py Outdated
skip_2 = 'ci.skip'
else:
skip_1, skip_2 = '', ''
self.git('push', force_flag, skip_1, skip_2, source, '%s:%s' % (branch, branch))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just have:

skip_flag = ['-o', 'ci.skip'] if skip_ci else []

and then:

self.git('push', force_flag, *skip_flag, source, ...)

David Szervanszky added 2 commits May 15, 2020 12:16
This commit is still missing the logic to ensure
that the individual MR hashes and those in the
batch MR match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants