Support tags for input args

Enable users to specify tags to be used to import and reference commits.

Change-Id: If2a9a2fa52d6c34ab110ae7a7fdbd02fae82e3b9
Closes-Bug: #1547180
This commit is contained in:
Darragh Bailey 2016-09-27 17:52:41 +01:00
parent 5f4038e268
commit be781cc50b
3 changed files with 21 additions and 3 deletions

View File

@ -304,7 +304,7 @@ class UpstreamMergeBaseSearcher(LogDedentMixin, Searcher):
["refs/remotes/*/{0}".format(ref) for ref in self.patterns])
if search_tags:
self._references.append(
self._references.extend(
["refs/tags/{0}".format(ref) for ref in self.patterns])
@property

View File

@ -116,8 +116,8 @@ class LocateChangesWalk(LocateChangesStrategy):
super(LocateChangesWalk, self).__init__(*args, **kwargs)
self.searcher = UpstreamMergeBaseSearcher(branch=branch,
patterns=search_refs)
self.searcher = UpstreamMergeBaseSearcher(
branch=branch, patterns=search_refs, search_tags=True)
@property
def previous_upstream(self):

View File

@ -101,6 +101,24 @@ class TestImportCommand(TestWithScenarios, BaseTestCase):
self._check_tree_state()
def test_command_with_tags(self):
# add tag for each branch/ref and test with added tag
parser_args = []
for arg in self.parser_args:
if (arg.startswith('-') or arg in ("import",)):
parser_args.append(arg)
continue
tag_name = "tag-gu-%s" % arg.replace('~', '-')
self.git.tag(tag_name, arg)
parser_args.append(tag_name)
args = self.parser.parse_args(parser_args)
self.assertThat(args.cmd.run(args), Equals(True),
"import command failed to complete successfully")
self._check_tree_state()
def _check_tree_state(self):
expected = getattr(self, 'expect_found', None)