add configuration option to not stop at branch base

The previous commit changes the default behavior to always stop scanning
at the base of a branch. This change adds a configuration option to
allow that behavior to be disabled, so that revisions along the history
of the branch prior to the point where it diverged from master can be
included. The new default behavior established in the previous commit is
not changed.

Change-Id: I2c4968e1291c1b7d268896cfbb79e320d4085bce
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-10-10 15:34:51 -04:00
parent 6f6e7addfb
commit 7ee2a78a8a
7 changed files with 58 additions and 2 deletions

View File

@ -160,6 +160,7 @@ configuration file. For example, a couple reno commands allow you to specify
- ``--earliest-version``
- ``--collapse-pre-releases``/``--no-collapse-pre-releases``
- ``--ignore-cache``
- ``--stop-at-branch-base``/``--no-stop-at-branch-base``
So you might write a config file (if you use these often) like:
@ -169,6 +170,7 @@ So you might write a config file (if you use these often) like:
branch: master
earliest_version: 12.0.0
collapse_pre_releases: false
stop_at_branch_base: true
These will be parsed first and then the CLI options will be applied after
the config files.

View File

@ -0,0 +1,9 @@
---
features:
- Add a new configuration option, stop_at_branch_base, to control
whether or not the scanner stops looking for changes at the point
where a branch diverges from master. The default is True, meaning
that the scanner does stop. A false value means that versions that
appear on master from a point earlier than when the branch was
created will be included when scanning the branch for release
notes.

View File

@ -32,6 +32,10 @@ class Config(object):
# of the same number (1.0.0.0a1 notes appear under 1.0.0).
'collapse_pre_releases': True,
# Should the scanner stop at the base of a branch (True) or go
# ahead and scan the entire history (False)?
'stop_at_branch_base': True,
# The git branch to scan. Defaults to the "current" branch
# checked out.
'branch': None,

View File

@ -44,6 +44,15 @@ _query_args = [
dict(default=False,
action='store_true',
help='if there is a cache file present, do not use it')),
(('--stop-at-branch-base',),
dict(action='store_true',
default=True,
dest='stop_at_branch_base',
help='stop scanning when the branch meets master')),
(('--no-stop-at-branch-base',),
dict(action='store_false',
dest='stop_at_branch_base',
help='do not stop scanning when the branch meets master')),
]

View File

@ -224,13 +224,15 @@ def get_notes_by_version(conf):
branch = conf.branch
earliest_version = conf.earliest_version
collapse_pre_releases = conf.collapse_pre_releases
stop_at_branch_base = conf.stop_at_branch_base
LOG.debug('scanning %s/%s (branch=%s)' % (reporoot, notesdir, branch))
# If the user has not told us where to stop, try to work it out
# for ourselves. If branch is set and is not "master", then we
# want to stop at the base of the branch.
if (not earliest_version) and branch and (branch != 'master'):
if (stop_at_branch_base and
(not earliest_version) and branch and (branch != 'master')):
LOG.debug('determining earliest_version from branch')
earliest_version = _get_branch_base(reporoot, branch)
if earliest_version and collapse_pre_releases:

View File

@ -36,6 +36,7 @@ class ReleaseNotesDirective(rst.Directive):
'version': directives.unchanged,
'collapse-pre-releases': directives.flag,
'earliest-version': directives.unchanged,
'stop-at-branch-base': directives.flag,
}
def run(self):
@ -56,10 +57,11 @@ class ReleaseNotesDirective(rst.Directive):
if 'notesdir' in self.options:
opt_overrides['notesdir'] = self.options.get('notesdir')
version_opt = self.options.get('version')
# FIXME(dhellmann): Force this flag True for now and figure
# FIXME(dhellmann): Force these flags True for now and figure
# out how Sphinx passes a "false" flag later.
# 'collapse-pre-releases' in self.options
opt_overrides['collapse_pre_releases'] = True
opt_overrides['stop_at_branch_base'] = True
if 'earliest-version' in self.options:
opt_overrides['earliest_version'] = self.options.get(
'earliest-version')

View File

@ -821,6 +821,34 @@ class BranchTest(Base):
results,
)
def test_files_stable_from_master_no_stop_base(self):
self._run_git('checkout', '2.0.0')
self._run_git('checkout', '-b', 'stable/2')
f21 = self._add_notes_file('slug21')
self._run_git('checkout', 'master')
log_text = self._run_git('log', '--pretty=%x00%H %d', '--name-only',
'stable/2')
self.addDetail('git log', text_content(log_text))
self.c.override(
branch='stable/2',
)
self.c.override(
stop_at_branch_base=False,
)
raw_results = scanner.get_notes_by_version(self.c)
results = {
k: [f for (f, n) in v]
for (k, v) in raw_results.items()
}
self.assertEqual(
{
'1.0.0': [self.f1],
'2.0.0': [self.f2],
'2.0.0-1': [f21],
},
results,
)
def test_pre_release_branch_no_collapse(self):
f4 = self._add_notes_file('slug4')
self._run_git('tag', '-s', '-m', 'pre-release', '4.0.0.0rc1')