Merge "add option for ignoring some notes files"
This commit is contained in:
@@ -59,6 +59,13 @@ Enable the extension by adding ``'reno.sphinxext'`` to the
|
|||||||
typically set to the version used to create the branch to limit
|
typically set to the version used to create the branch to limit
|
||||||
the output to only versions on that branch.
|
the output to only versions on that branch.
|
||||||
|
|
||||||
|
*ignore-notes*
|
||||||
|
|
||||||
|
A string containing a comma-delimited list of filenames or UIDs
|
||||||
|
for notes that should be ignored by the scanner. It is most
|
||||||
|
useful to set this when a note is edited on the wrong branch,
|
||||||
|
making it appear to be part of a release that it is not.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
========
|
========
|
||||||
|
|
||||||
|
|||||||
@@ -299,6 +299,19 @@ The following options are configurable:
|
|||||||
|
|
||||||
Defaults to ``True``.
|
Defaults to ``True``.
|
||||||
|
|
||||||
|
`ignore_notes`
|
||||||
|
|
||||||
|
A list of filenames or UIDs for notes that should be ignored by the
|
||||||
|
reno scanner. It is most useful to set this when a note is edited on
|
||||||
|
the wrong branch, making it appear to be part of a release that it
|
||||||
|
is not.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Setting the option in the main configuration file makes it apply
|
||||||
|
to all branches. To ignore a note in the HTML build, use the
|
||||||
|
``ignore-notes`` parameter to the ``release-notes`` sphinx
|
||||||
|
directive.
|
||||||
|
|
||||||
Debugging
|
Debugging
|
||||||
=========
|
=========
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add a new configuration option ``ignore_notes``. Setting the value
|
||||||
|
to a list of filenames or UIDs for notes causes the reno scanner
|
||||||
|
to ignore them. It is most useful to set this when a note is
|
||||||
|
edited on the wrong branch, making it appear to be part of a
|
||||||
|
release that it is not.
|
||||||
@@ -167,6 +167,12 @@ class Config(object):
|
|||||||
# branch appear to be part of master and/or the later stable
|
# branch appear to be part of master and/or the later stable
|
||||||
# branch. This option allows us to ignore those.
|
# branch. This option allows us to ignore those.
|
||||||
'ignore_null_merges': True,
|
'ignore_null_merges': True,
|
||||||
|
|
||||||
|
# Note files to be ignored. It's useful to be able to ignore a
|
||||||
|
# file if it is edited on the wrong branch. Notes should be
|
||||||
|
# specified by their filename or UID. Setting the value in the
|
||||||
|
# configuration file makes it apply to all branches.
|
||||||
|
'ignore_notes': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -514,6 +514,10 @@ class Scanner(object):
|
|||||||
self.conf.branch_name_re,
|
self.conf.branch_name_re,
|
||||||
flags=re.VERBOSE | re.UNICODE,
|
flags=re.VERBOSE | re.UNICODE,
|
||||||
)
|
)
|
||||||
|
self._ignore_uids = set(
|
||||||
|
_get_unique_id(fn)
|
||||||
|
for fn in self.conf.ignore_notes
|
||||||
|
)
|
||||||
|
|
||||||
def _get_ref(self, name):
|
def _get_ref(self, name):
|
||||||
if name:
|
if name:
|
||||||
@@ -1069,6 +1073,11 @@ class Scanner(object):
|
|||||||
for change in aggregator.aggregate_changes(entry, changes):
|
for change in aggregator.aggregate_changes(entry, changes):
|
||||||
uniqueid = change[0]
|
uniqueid = change[0]
|
||||||
|
|
||||||
|
if uniqueid in self._ignore_uids:
|
||||||
|
LOG.info('ignoring %s based on configuration setting',
|
||||||
|
uniqueid)
|
||||||
|
continue
|
||||||
|
|
||||||
c_type = change[1]
|
c_type = change[1]
|
||||||
|
|
||||||
if c_type == diff_tree.CHANGE_ADD:
|
if c_type == diff_tree.CHANGE_ADD:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class ReleaseNotesDirective(rst.Directive):
|
|||||||
'collapse-pre-releases': directives.flag,
|
'collapse-pre-releases': directives.flag,
|
||||||
'earliest-version': directives.unchanged,
|
'earliest-version': directives.unchanged,
|
||||||
'stop-at-branch-base': directives.flag,
|
'stop-at-branch-base': directives.flag,
|
||||||
|
'ignore-notes': directives.unchanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -57,6 +58,10 @@ class ReleaseNotesDirective(rst.Directive):
|
|||||||
reporoot = repo.Repo.discover(reporoot).path
|
reporoot = repo.Repo.discover(reporoot).path
|
||||||
relnotessubdir = self.options.get('relnotessubdir',
|
relnotessubdir = self.options.get('relnotessubdir',
|
||||||
defaults.RELEASE_NOTES_SUBDIR)
|
defaults.RELEASE_NOTES_SUBDIR)
|
||||||
|
ignore_notes = [
|
||||||
|
name.strip()
|
||||||
|
for name in self.options.get('ignore-notes', '').split(',')
|
||||||
|
]
|
||||||
conf = config.Config(reporoot, relnotessubdir)
|
conf = config.Config(reporoot, relnotessubdir)
|
||||||
opt_overrides = {}
|
opt_overrides = {}
|
||||||
if 'notesdir' in self.options:
|
if 'notesdir' in self.options:
|
||||||
@@ -74,6 +79,8 @@ class ReleaseNotesDirective(rst.Directive):
|
|||||||
'earliest-version')
|
'earliest-version')
|
||||||
if branch:
|
if branch:
|
||||||
opt_overrides['branch'] = branch
|
opt_overrides['branch'] = branch
|
||||||
|
if ignore_notes:
|
||||||
|
opt_overrides['ignore_notes'] = ignore_notes
|
||||||
conf.override(**opt_overrides)
|
conf.override(**opt_overrides)
|
||||||
|
|
||||||
notesdir = os.path.join(relnotessubdir, conf.notesdir)
|
notesdir = os.path.join(relnotessubdir, conf.notesdir)
|
||||||
|
|||||||
@@ -660,6 +660,88 @@ class BasicTest(Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class IgnoreTest(Base):
|
||||||
|
|
||||||
|
def test_by_fullname(self):
|
||||||
|
self._make_python_package()
|
||||||
|
self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
|
||||||
|
f1 = self._add_notes_file()
|
||||||
|
f2 = self._add_notes_file()
|
||||||
|
self.c.override(
|
||||||
|
ignore_notes=[f1],
|
||||||
|
)
|
||||||
|
self.scanner = scanner.Scanner(self.c)
|
||||||
|
raw_results = self.scanner.get_notes_by_version()
|
||||||
|
results = {
|
||||||
|
k: [f for (f, n) in v]
|
||||||
|
for (k, v) in raw_results.items()
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
{'1.0.0-2': [f2]},
|
||||||
|
results,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_by_basename(self):
|
||||||
|
self._make_python_package()
|
||||||
|
self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
|
||||||
|
f1 = self._add_notes_file()
|
||||||
|
f2 = self._add_notes_file()
|
||||||
|
self.c.override(
|
||||||
|
ignore_notes=[os.path.basename(f1)],
|
||||||
|
)
|
||||||
|
self.scanner = scanner.Scanner(self.c)
|
||||||
|
raw_results = self.scanner.get_notes_by_version()
|
||||||
|
results = {
|
||||||
|
k: [f for (f, n) in v]
|
||||||
|
for (k, v) in raw_results.items()
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
{'1.0.0-2': [f2]},
|
||||||
|
results,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_by_uid(self):
|
||||||
|
self._make_python_package()
|
||||||
|
self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
|
||||||
|
f1 = self._add_notes_file()
|
||||||
|
f2 = self._add_notes_file()
|
||||||
|
self.c.override(
|
||||||
|
ignore_notes=[scanner._get_unique_id(f1)],
|
||||||
|
)
|
||||||
|
self.scanner = scanner.Scanner(self.c)
|
||||||
|
raw_results = self.scanner.get_notes_by_version()
|
||||||
|
results = {
|
||||||
|
k: [f for (f, n) in v]
|
||||||
|
for (k, v) in raw_results.items()
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
{'1.0.0-2': [f2]},
|
||||||
|
results,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_by_multiples(self):
|
||||||
|
self._make_python_package()
|
||||||
|
self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
|
||||||
|
f1 = self._add_notes_file()
|
||||||
|
f2 = self._add_notes_file()
|
||||||
|
self.c.override(
|
||||||
|
ignore_notes=[
|
||||||
|
scanner._get_unique_id(f1),
|
||||||
|
scanner._get_unique_id(f2),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.scanner = scanner.Scanner(self.c)
|
||||||
|
raw_results = self.scanner.get_notes_by_version()
|
||||||
|
results = {
|
||||||
|
k: [f for (f, n) in v]
|
||||||
|
for (k, v) in raw_results.items()
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
{},
|
||||||
|
results,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FileContentsTest(Base):
|
class FileContentsTest(Base):
|
||||||
|
|
||||||
def test_basic_file(self):
|
def test_basic_file(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user