From 4134ccc202cfa9b6f17111e3172a4242d69505d5 Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Sun, 15 May 2016 23:48:14 -0400 Subject: [PATCH] Adjust generation of ChangeLog and Release Notes. --- releasetools/Targets.mk | 45 ++------------ releasetools/Variables.mk | 22 +------ releasetools/changelog.py | 58 +++++++++++++++++++ ...{svnlog2docbook.xsl => gitlog2docbook.xsl} | 39 ++++--------- xsl/Makefile | 2 +- xsl/RELEASE-NOTES.xml | 3 + 6 files changed, 80 insertions(+), 89 deletions(-) create mode 100644 releasetools/changelog.py rename releasetools/{svnlog2docbook.xsl => gitlog2docbook.xsl} (92%) diff --git a/releasetools/Targets.mk b/releasetools/Targets.mk index 827edbced..0f0509e78 100644 --- a/releasetools/Targets.mk +++ b/releasetools/Targets.mk @@ -5,7 +5,7 @@ debug: -.PHONY: ChangeLog.xml ChangeHistory.xml $(SVN_INFO_FILE) +.PHONY: ChangeLog.xml ChangeHistory.xml RELEASE-NOTES.html: RELEASE-NOTES.xml NEWS.xml $(XINCLUDE) $< > RELEASE-NOTES-TMP.xml @@ -38,7 +38,7 @@ ifeq ($(PDF_MAKER),xep) else ifeq ($(PDF_MAKER),dblatex) $(XSLT) RELEASE-NOTES-TMP.xml $(STRIP_NS) RELEASE-NOTES-STRIPPED-TMP.xml \ - -$(DBLATEX) $(DBLATEX_FLAGS) \ + && $(DBLATEX) $(DBLATEX_FLAGS) \ -p $(DBX_STYLE) \ -o $@ \ RELEASE-NOTES-STRIPPED-TMP.xml @@ -51,10 +51,7 @@ $(MARKUP_XSL): $(MAKE) -C $(dir $(MARKUP_XSL)) NEWS.xml: ChangeLog.xml - $(XSLT) $< $(SVNLOG2DOCBOOK) $@ \ - repositoryRoot="$(REPOSITORY_ROOT)" \ - distroParentUrl="$(DISTRO_PARENT_URL)" \ - distro="$(DISTRO)" \ + $(XSLT) $< $(GITLOG2DOCBOOK) $@ \ previous-release="$(PREVIOUS_RELEASE)" \ release-version="$(RELVER)" \ element.file="$(DOCBOOK_ELEMENTS)" \ @@ -71,16 +68,8 @@ NEWS.html: NEWS.xml $(NEWSFILE): NEWS.html $(BROWSER) $(BROWSER_OPTS) $< > $@ -$(SVN_INFO_FILE): - $(SVN) $(SVN_OPTS) info --xml \ - | $(XMLLINT) $(XMLLINT_OPTS) --format - > $@ - -ChangeLog.xml: $(SVN_INFO_FILE) - $(SVN) $(SVN_OPTS) log --xml --verbose \ - -r HEAD:$(PREVIOUS_REVISION) \ - $(DISTRO_PARENT_URL) \ - $(DISTRO) $(DISTRIB_CHANGELOG_INCLUDES) \ - | $(XMLLINT) $(XMLLINT_OPTS) --format - > $@ +ChangeLog.xml: + python $(repo_dir)/releasetools/changelog.py > $@ ChangeHistory.xml.zip: ChangeHistory.xml $(ZIP) $(ZIP_OPTS) $@ $< @@ -89,7 +78,7 @@ ChangeHistory.xml.zip: ChangeHistory.xml # ChangeHistory.xml holds the whole change history for the module, # including all subdirectories ChangeHistory.xml: - $(SVN) $(SVN_OPTS) log --xml --verbose > $@ + python $(repo_dir)/releasetools/changelog.py all > $@ .CatalogManager.properties.example: cp -p $(CATALOGMANAGER) .CatalogManager.properties.example @@ -250,27 +239,6 @@ install: $(INSTALL_DEPENDS) upload-to-sf-incoming upload-to-project-webspace announce: $(ANNOUNCE_CHANGES) .announcement-text $(RELEASE_ANNOUNCE) "$(DISTRO_TITLE)" "$(RELVER)" .announcement-text $< "$(ANNOUNCE_RECIPIENTS)" -tag: -ifeq (,$(shell git status --porcelain)) -ifneq (,$(shell svn info $(REPOSITORY_ROOT)/tags/$(TAG)/$(DISTRO) 2>/dev/null)) - $(SVN) $(SVN_OPTS) delete -m "deleting the $(DISTRO) $(ZIPVER) tag" \ - $(REPOSITORY_ROOT)/tags/$(TAG)/$(DISTRO) -endif -ifeq (,$(shell svn info $(REPOSITORY_ROOT)/tags/$(TAG) 2>/dev/null)) - $(SVN) $(SVN_OPTS) mkdir -m "creating the $(ZIPVER) tag" \ - $(REPOSITORY_ROOT)/tags/$(TAG) -endif - $(SVN) $(SVN_OPTS) copy -m "tagging the $(DISTRO) $(ZIPVER) release" \ - -r $(REVISION) $(DISTRO_URL) $(REPOSITORY_ROOT)/tags/$(TAG)/$(DISTRO) -else - @echo "Unversioned or uncommitted files found. Before tagging/uploading" - @echo "the release, either delete the following files, add them to the" - @echo "repository, or add them to the svn:ignore properties for their" - @echo "parent directories." - @echo - @svn status -endif - release-clean: clean $(RELEASE_CLEAN_TARGETS) $(RM) TERMS.xml $(RM) $(NEWSFILE) @@ -280,7 +248,6 @@ release-clean: clean $(RELEASE_CLEAN_TARGETS) $(RM) ChangeHistory.xml $(RM) ChangeHistory.xml.zip $(RM) ChangeLog.xml - $(RM) $(SVN_INFO_FILE) $(RM) RELEASE-NOTES.txt $(RM) RELEASE-NOTES.html $(RM) RELEASE-NOTES.fo diff --git a/releasetools/Variables.mk b/releasetools/Variables.mk index 3982ebaa0..aa12a2912 100644 --- a/releasetools/Variables.mk +++ b/releasetools/Variables.mk @@ -93,28 +93,11 @@ else MARKUP_XSL=$(repo_dir)/releasetools/modified-markup.xsl endif -# stylesheet used in taking XML output from "svn log" and using it -# to generate NEWS file(s) and releases notes -ifneq ($(shell uname -s | grep -i cygwin),) -ifeq ($(XSLTENGINE),saxon) -SVNLOG2DOCBOOK=../releasetools/svnlog2docbook.xsl -else -SVNLOG2DOCBOOK=$(repo_dir)/releasetools/svnlog2docbook.xsl -endif -else -SVNLOG2DOCBOOK=$(repo_dir)/releasetools/svnlog2docbook.xsl -endif - -SVN_INFO_FILE=.svninfo.xml +GITLOG2DOCBOOK=$(repo_dir)/releasetools/gitlog2docbook.xsl PREVIOUS_RELEASE=$(shell $(XSLTPROC) --stringparam get PreviousRelease VERSION.xsl VERSION.xsl | $(GREP) $(GREPFLAGS) -v "xml version=") DISTRO_TITLE=$(shell $(XSLTPROC) --stringparam get DistroTitle VERSION.xsl VERSION.xsl | $(GREP) $(GREPFLAGS) -v "xml version=") -REPOSITORY_ROOT=$(shell if [ -f $(SVN_INFO_FILE) ]; then $(XSLTPROC) --stringparam expression //root $(EVALXPATH) $(SVN_INFO_FILE) | $(GREP) $(GREPFLAGS) -v "xml version="; fi) -DISTRO_URL=$(shell if [ -f $(SVN_INFO_FILE) ]; then $(XSLTPROC) --stringparam expression //url $(EVALXPATH) $(SVN_INFO_FILE) | $(GREP) $(GREPFLAGS) -v "xml version="; fi) -REVISION=$(shell if [ -f $(SVN_INFO_FILE) ]; then $(XSLTPROC) --stringparam expression //commit/@revision $(EVALXPATH) $(SVN_INFO_FILE) | $(GREP) $(GREPFLAGS) -v "xml version="; fi) -DISTRO_PARENT_URL=$(dir $(basename $(DISTRO_URL))) - # stylesheet for stripping DB5 namespace STRIP_NS=common/stripns.xsl @@ -256,9 +239,6 @@ XMLLINT=xmllint XMLLINT_OPTS=--noent XINCLUDE=$(XMLLINT) $(XMLLINT_OPTS) --xinclude -SVN=svn -SVN_OPTS= - SED=sed SED_OPTS= diff --git a/releasetools/changelog.py b/releasetools/changelog.py new file mode 100644 index 000000000..230557e7b --- /dev/null +++ b/releasetools/changelog.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +import subprocess +import xml.etree.ElementTree as ET +import sys + +all = len(sys.argv) == 2 and sys.argv[-1] == 'all' + +GIT_COMMIT_FIELDS = ['id', 'author_name', 'author_email', 'date', 'message', 'paths'] +GIT_LOG_FORMAT = ['%H', '%an', '%ae', '%ad', '%s'] +# +# git's --format specifier doesn't cover the list of files (which can be generated +# with '--name-only' and '--name-status'. +# To be able to identify that path list we inject a '001e' character at the very +# beginning of each entry. Then, the list of paths is the last chunk of each entry +# following an empty line. +GIT_LOG_FORMAT = '%x1e' + '%x1f'.join(GIT_LOG_FORMAT) +command = ['git', 'log', '--format=%s' % GIT_LOG_FORMAT, '--name-only'] +if not all: + # Determine the last release tag and limit history to then. + release = ['git', 'describe', '--tags', '--match', 'release/*', '--abbrev=0'] + out = subprocess.check_output(release) + out = out.strip() + command.append('%s..HEAD'%out.decode(encoding='UTF-8')) +out = subprocess.check_output(command) +out = out.decode(encoding='UTF-8') +entries = out.strip('\n\x1e').split('\x1e') +entries = [row.strip().split('\x1f') for row in entries] +# separate paths from message +for entry in entries: + t = entry[-1].rsplit('\n\n', 1) + entry[-1] = t[0] + entry.append(len(t) == 2 and t[1].split('\n') or '') +entries = [dict(zip(GIT_COMMIT_FIELDS, entry)) for entry in entries] + +builder = ET.TreeBuilder() +builder.start('log', {}) +for e in entries: + builder.start('logentry', {'revision':e['id']}) + builder.start('author', {}) + builder.data(e['author_name']) + builder.end('author') + builder.start('date', {}) + builder.data(e['date']) + builder.end('date') + builder.start('msg', {}) + builder.data(e['message']) + builder.end('msg') + builder.start('paths', {}) + for p in e['paths']: + builder.start('path', {}) + builder.data(p) + builder.end('path') + builder.end('paths') + builder.end('logentry') +builder.end('log') +root = builder.close() +print(ET.tostring(root, encoding='utf-8')) diff --git a/releasetools/svnlog2docbook.xsl b/releasetools/gitlog2docbook.xsl similarity index 92% rename from releasetools/svnlog2docbook.xsl rename to releasetools/gitlog2docbook.xsl index 3f8591c4c..5ca621178 100644 --- a/releasetools/svnlog2docbook.xsl +++ b/releasetools/gitlog2docbook.xsl @@ -22,17 +22,8 @@ - - - - - - - - - - + xsl @@ -158,15 +149,7 @@ Note: This document lists changes only since the release. - If you instead want a record of the complete list of - changes for the codebase over its entire history, you - can obtain one by running the following commands: - - svn checkout - - svn log --xml --verbose > ChangeHistory.xml - + @@ -225,8 +208,8 @@ @@ -280,8 +263,8 @@ @@ -298,8 +281,8 @@ @@ -307,12 +290,12 @@ - - + + - + diff --git a/xsl/Makefile b/xsl/Makefile index 8909e9e97..8cc7ad33e 100644 --- a/xsl/Makefile +++ b/xsl/Makefile @@ -1,4 +1,4 @@ -: Makefile 9654 2012-10-28 22:54:32Z stefan $ +export repo_dir ?= $(abspath ../) include $(repo_dir)/buildtools/Makefile.incl include $(repo_dir)/releasetools/Variables.mk diff --git a/xsl/RELEASE-NOTES.xml b/xsl/RELEASE-NOTES.xml index 205812f9b..d2c13d60a 100644 --- a/xsl/RELEASE-NOTES.xml +++ b/xsl/RELEASE-NOTES.xml @@ -54,6 +54,9 @@ public APIs (user-configurable parameters).--> +
+ +
Release Notes: 1.79.1 The following is a list of changes that have been made -- 2.40.0