diff --git a/git_upstream/commands/import.py b/git_upstream/commands/import.py index a741b66..3a21b57 100644 --- a/git_upstream/commands/import.py +++ b/git_upstream/commands/import.py @@ -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): diff --git a/git_upstream/lib/importupstream.py b/git_upstream/lib/importupstream.py index 4426ba9..852a346 100644 --- a/git_upstream/lib/importupstream.py +++ b/git_upstream/lib/importupstream.py @@ -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}") != \ diff --git a/git_upstream/tests/commands/import/scenarios/import_finish.yaml b/git_upstream/tests/commands/import/scenarios/import_finish.yaml index cdb7eca..828b5e2 100644 --- a/git_upstream/tests/commands/import/scenarios/import_finish.yaml +++ b/git_upstream/tests/commands/import/scenarios/import_finish.yaml @@ -62,3 +62,4 @@ - --finish - --import-branch=import/F - --into=master + - custom/master diff --git a/git_upstream/tests/commands/import/scenarios/import_same_as_previous_upstream.yaml b/git_upstream/tests/commands/import/scenarios/import_same_as_previous_upstream.yaml index 1d7ba74..1fda1df 100644 --- a/git_upstream/tests/commands/import/scenarios/import_same_as_previous_upstream.yaml +++ b/git_upstream/tests/commands/import/scenarios/import_same_as_previous_upstream.yaml @@ -41,3 +41,4 @@ - --into=master expect_found: [] + check_merge: False diff --git a/git_upstream/tests/commands/import/scenarios/import_same_previous_with_same_additional.yaml b/git_upstream/tests/commands/import/scenarios/import_same_previous_with_same_additional.yaml index 4779b8a..4a1a796 100644 --- a/git_upstream/tests/commands/import/scenarios/import_same_previous_with_same_additional.yaml +++ b/git_upstream/tests/commands/import/scenarios/import_same_previous_with_same_additional.yaml @@ -53,3 +53,4 @@ - additional/2 expect_found: [] + check_merge: False diff --git a/git_upstream/tests/commands/import/test_import.py b/git_upstream/tests/commands/import/test_import.py index c3dff15..43f6f5a 100644 --- a/git_upstream/tests/commands/import/test_import.py +++ b/git_upstream/tests/commands/import/test_import.py @@ -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: