Merge "Record upstream branch in import merge commit"

This commit is contained in:
Jenkins
2016-09-16 13:48:13 +00:00
committed by Gerrit Code Review
6 changed files with 22 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ class ImportCommand(LogDedentMixin, GitUpstreamCommand):
def finalize(self):
"""Perform additional parsing of args"""
if self.args.finish:
if self.args.finish and not self.args.upstream_branch:
self.args.upstream_branch = self.args.import_branch
def _finish(self, import_upstream):

View File

@@ -369,6 +369,11 @@ class ImportUpstream(LogDedentMixin, GitMixin):
self.git.checkout(self.branch)
current_sha = self.git.rev_parse("HEAD")
commit_message = (
"Merge branch '{0}' into {1}\n\n"
"Import of '{2}' into '{1}'."
).format(self.import_branch, self.branch, self.upstream)
try:
self.log.info(
"""
@@ -390,9 +395,9 @@ class ImportUpstream(LogDedentMixin, GitMixin):
self.log.info(
"""
Committing merge commit:
git commit --no-edit
""")
self.git.commit(no_edit=True)
git commit -m "%s"
""", commit_message.replace('\n', '\n' + ' ' * 4))
self.git.commit(m=commit_message)
# finally test that everything worked correctly by comparing if
# the tree object id's match
if self.git.rev_parse("HEAD^{tree}") != \

View File

@@ -62,3 +62,4 @@
- --finish
- --import-branch=import/F
- --into=master
- custom/master

View File

@@ -41,3 +41,4 @@
- --into=master
expect_found: []
check_merge: False

View File

@@ -53,3 +53,4 @@
- additional/2
expect_found: []
check_merge: False

View File

@@ -52,6 +52,8 @@ class TestImportCommand(TestWithScenarios, BaseTestCase):
"import command failed to complete successfully")
expected = getattr(self, 'expect_found', None)
# even if empty want to confirm that find no changes applied,
# otherwise confirm we find the expected number of changes.
if expected is not None:
if len(list(Commit.new(self.repo, target_branch).parents)) > 1:
changes = list(Commit.iter_items(
@@ -82,6 +84,14 @@ class TestImportCommand(TestWithScenarios, BaseTestCase):
subject, commit.hexsha, node_subject,
node))
# allow disabling of checking the merge commit contents
# as some tests won't result in an import
if getattr(self, 'check_merge', True):
commit_message = self.git.log(target_branch, n=1)
self.assertThat(commit_message,
Contains("of '%s' into '%s'" % (upstream_branch,
target_branch)))
# allow additional test specific verification methods below
extra_test_func = getattr(self, '_verify_%s' % self.name, None)
if extra_test_func: