fix a problem scanning for the base of a branch with no tag

When there is no tag at the base of a branch, the scanner cannot figure
out where to stop scanning. Avoid an exception and allow the scanner to
continue to the end of the history.

Change-Id: I9bed42724d5ab0e8d11ab0c781e215a71af5e99a
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2016-12-22 09:08:21 -05:00
parent 7239f6c071
commit 51986ae2b9
2 changed files with 18 additions and 1 deletions

View File

@@ -385,7 +385,15 @@ class Scanner(object):
# on master, so this is the base.
tags = self._repo.get_tags_on_commit(
c.commit.sha().hexdigest().encode('ascii'))
return tags[-1]
if tags:
return tags[-1]
else:
# Naughty, naughty, branching without tagging.
LOG.error(
('There is no tag on commit %s at the base of %s. '
'Branch scan short-cutting is disabled.'),
c.commit.sha().hexdigest(), branch)
return None
return None
def _topo_traversal(self, branch):

View File

@@ -933,6 +933,15 @@ class BranchBaseTest(Base):
self.scanner._get_branch_base('not-master'),
)
def test_no_tag_at_base(self):
# remove the tag at the branch point
self.repo.git('tag', '-d', '2.0.0')
self._add_notes_file('slug4')
self.repo.git('checkout', 'master')
self.assertIsNone(
self.scanner._get_branch_base('not-master')
)
class BranchTest(Base):