Keep scanning master branch after first shared commit

If no earliest version is provided for a branch, reno will scan commits
on the branch in reverse order, attempting to find a common ancestor
with the master branch. Currently, the first patch this finds must be
the tagged one or it will quit early. There's no particular reason to do
this. Instead, we can keep going for a little longer. This is helpful
for situations where we haven't branched off straight after the tag.

Change-Id: Ic0ed1305cf21deb6abea0991ec604d7f9b821622
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-04-05 21:08:59 +01:00
parent 4a93566f49
commit 370f1a5c7b
3 changed files with 28 additions and 9 deletions

View File

@ -0,0 +1,10 @@
---
features:
- |
If no earliest version is provided for a branch, reno will scan commits
on the branch in reverse order, attempting to find a common ancestor
with the master branch. Once found, the last common commit - the branch
point - is checked for a tag. Previously, if no tag was found, reno
would stop scanning. This was problematic for instances where a branch
was not created at the tagged commit but rather some commits later.
Reno will now continue scanning until it finds a tag.

View File

@ -659,13 +659,13 @@ class Scanner(object):
c.commit.sha().hexdigest().encode('ascii'))
if tags:
return tags[-1]
else:
# Naughty, naughty, branching without tagging.
LOG.info(
('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
# Naughty, naughty, branching without tagging.
LOG.info(
'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
def _topo_traversal(self, branch):

View File

@ -1271,10 +1271,19 @@ class BranchBaseTest(Base):
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')
self.assertEqual(
'1.0.0',
self.scanner._get_branch_base('not-master'),
)
def test_no_tags(self):
# remove all tags from before the branch
self.repo.git('tag', '-d', '2.0.0')
self.repo.git('tag', '-d', '1.0.0')
self._add_notes_file('slug4')
self.repo.git('checkout', 'master')
self.assertIsNone(self.scanner._get_branch_base('not-master'))
class BranchTest(Base):