Add support for release dates
- Adds a new config option (default is false) - Adds ability to go from a tag to a date Change-Id: I14c566dc6b0220999dd803be5c7374c05acb4748
This commit is contained in:
5
releasenotes/notes/release-date-3a1dec42c91a3f0b.yaml
Normal file
5
releasenotes/notes/release-date-3a1dec42c91a3f0b.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add an option, ``add_release_date``, to print the release dates for every
|
||||
version.
|
@ -64,6 +64,12 @@ _OPTIONS = [
|
||||
The template used by reno new to create a note.
|
||||
""")),
|
||||
|
||||
Opt('add_release_date', False,
|
||||
textwrap.dedent("""\
|
||||
Should the report include release date (True) based on
|
||||
the date of objects associated with the release tag.
|
||||
""")),
|
||||
|
||||
Opt('release_tag_re',
|
||||
textwrap.dedent('''\
|
||||
((?:v?[\\d.ab]|rc)+) # digits, a, b, and rc cover regular and
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def _indent_for_list(text, prefix=' '):
|
||||
@ -71,6 +72,15 @@ def format_report(loader, config, versions_to_include, title=None,
|
||||
report.append('=' * len(version_title))
|
||||
report.append('')
|
||||
|
||||
if (config.add_release_date
|
||||
# Currently, this only works when the Scanner is used
|
||||
and loader._scanner is not None
|
||||
and version in loader._scanner._repo._tags_to_dates.keys()):
|
||||
date = datetime.fromtimestamp(
|
||||
loader._scanner._repo._tags_to_dates[version])
|
||||
report.append('Release Date: ' + date.strftime("%Y-%m-%d"))
|
||||
report.append('')
|
||||
|
||||
# Add the preludes.
|
||||
notefiles = loader[version]
|
||||
prelude_name = config.prelude_section_name
|
||||
|
@ -391,6 +391,7 @@ class RenoRepo(repo.Repo):
|
||||
# Populated by _load_tags().
|
||||
_all_tags = None
|
||||
_shas_to_tags = None
|
||||
_tags_to_dates = None
|
||||
|
||||
def _get_commit_from_tag(self, tag, tag_sha):
|
||||
"""Return the commit referenced by the tag and when it was tagged."""
|
||||
@ -434,9 +435,11 @@ class RenoRepo(repo.Repo):
|
||||
if k.startswith(b'refs/tags/')
|
||||
}
|
||||
self._shas_to_tags = {}
|
||||
self._tags_to_dates = {}
|
||||
for tag, tag_sha in self._all_tags.items():
|
||||
tagged_sha, date = self._get_commit_from_tag(tag, tag_sha)
|
||||
self._shas_to_tags.setdefault(tagged_sha, []).append((tag, date))
|
||||
self._tags_to_dates[tag] = date
|
||||
|
||||
def get_tags_on_commit(self, sha):
|
||||
"Return the tag(s) on a commit, in application order."
|
||||
|
Reference in New Issue
Block a user