]> granicus.if.org Git - docbook-dsssl/commitdiff
Adjust generation of ChangeLog and Release Notes.
authorStefan Seefeld <stefan@seefeld.name>
Mon, 16 May 2016 03:48:14 +0000 (23:48 -0400)
committerStefan Seefeld <stefan@seefeld.name>
Fri, 20 May 2016 16:50:28 +0000 (12:50 -0400)
releasetools/Targets.mk
releasetools/Variables.mk
releasetools/changelog.py [new file with mode: 0644]
releasetools/gitlog2docbook.xsl [moved from releasetools/svnlog2docbook.xsl with 92% similarity]
xsl/Makefile
xsl/RELEASE-NOTES.xml

index 827edbced758f0f392ff04dbce3eac56159e13b0..0f0509e78a09d2fd40a4cf3ac42d9be3eccaffba 100644 (file)
@@ -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
index 3982ebaa0baeccb2596d0c98214936a1f0c3b003..aa12a29127a9801703b881bfad374a5544cfe486 100644 (file)
@@ -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 (file)
index 0000000..230557e
--- /dev/null
@@ -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'))
similarity index 92%
rename from releasetools/svnlog2docbook.xsl
rename to releasetools/gitlog2docbook.xsl
index 3f8591c4c1b8be77c5100bad2465db4ae14157ad..5ca6211785bea75ba4dcda79b7a53fa93b5ddf50 100644 (file)
   <xsl:import href="./modified-markup.xsl" />
   <xsl:include href="../xsl/lib/lib.xsl" />
 
-  <!-- * RepositoryRoot is the same as what "svn info" shows -->
-  <xsl:param name="repositoryRoot"/>
-  <!-- * distroParentUrl is what "svn info" shows as "url"/URL for the parent -->
-  <!-- * of the distro dir -->
-  <xsl:param name="distroParentUrl"/>
-  <xsl:param name="distroParentDir">
-    <xsl:value-of select="substring-after($distroParentUrl,$repositoryRoot)"/>
-  </xsl:param>
-
   <!-- * name of main distro this changelog is for-->
-  <xsl:param name="distro"/>
+  <xsl:param name="distro">xsl</xsl:param>
 
   <!-- * file containing DocBook XSL stylesheet param names -->
   <xsl:param name="param.file"/>
           <para><emphasis role="strong">Note:</emphasis> This
             document lists changes only since the <xsl:value-of
               select="$previous-release"/> 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:
-            <xsl:text>&#xa;</xsl:text>
-<screen
-><xsl:text>  </xsl:text><code>svn checkout <xsl:value-of select="concat($distroParentUrl,$distro)"/></code>
-<xsl:text>&#xa;</xsl:text>
-<xsl:text>  </xsl:text><code>svn log --xml --verbose <xsl:value-of select="$distro"/> > ChangeHistory.xml</code></screen></para>
-            <xsl:text>&#xa;</xsl:text>
+         </para>
         </abstract>
         <xsl:text>&#xa;</xsl:text>
       </info>
       <!-- * for changed files in the $dirname subsection of the distro -->
       <!-- * OR in the $dirname sibling of the distro -->
       <xsl:if test="logentry[paths/path[
-        starts-with(.,concat($distroParentDir,$distro,'/',$dirname,'/'))
-        or starts-with(.,concat($distroParentDir,$dirname,'/'))]]
+        starts-with(.,concat($distro,'/',$dirname,'/'))
+        or starts-with(.,concat($dirname,'/'))]]
         ">
         <sect2>
           <!-- * the ID on each Sect2 is the release version plus the -->
     <xsl:for-each
       select="
       logentry[paths/path[
-      starts-with(.,concat($distroParentDir,$distro,'/',$dirname,'/'))
-      or starts-with(.,concat($distroParentDir,$dirname,'/'))]]
+      starts-with(.,concat($distro,'/',$dirname,'/'))
+      or starts-with(.,concat($dirname,'/'))]]
       ">
       <!-- * each Lisitem corresponds to a single commit -->
       <listitem>
               <!-- * that we are currently formatting -->
               <xsl:for-each select="
                 paths/path[
-                starts-with(.,concat($distroParentDir,$distro,'/',$dirname,'/'))
-                or starts-with(.,concat($distroParentDir,$dirname,'/'))]
+                starts-with(.,concat($distro,'/',$dirname,'/'))
+                or starts-with(.,concat($dirname,'/'))]
                 ">
                 <!-- * for each changed file we list, we don't want to show -->
                 <!-- * its whole repository path back to the repository -->
                 <xsl:variable name="pathprefix">
                   <xsl:choose>
                     <!-- * first case, changed file is in a subdir of distro -->
-                    <xsl:when test="contains(.,(concat($distroParentDir,$dirname,'/')))">
-                      <xsl:value-of select="concat($distroParentDir,$dirname,'/')"/>
+                    <xsl:when test="contains(.,(concat($dirname,'/')))">
+                      <xsl:value-of select="concat($dirname,'/')"/>
                     </xsl:when>
                     <!-- * other case, changed file is in a sibling dir of distro -->
                     <xsl:otherwise>
-                      <xsl:value-of select="concat($distroParentDir,$distro,'/',$dirname,'/')"/>
+                      <xsl:value-of select="concat($distro,'/',$dirname,'/')"/>
                     </xsl:otherwise>
                   </xsl:choose>
                 </xsl:variable>
index 8909e9e978e5ba9d6dc66a8129d528d5bdc1ae6e..8cc7ad33e3dc762f34c620e5a9ab55b12b4828e7 100644 (file)
@@ -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
index 205812f9bf8089d7eb764456f40c62144ddb7672..d2c13d60aec532bef6d7b675c830902dfcc30b57 100644 (file)
@@ -54,6 +54,9 @@ public APIs (user-configurable parameters).</para>-->
 </abstract>
 </info>
 
+<section condition="snapshot" xml:id="current">
+  <xi:include href="NEWS.xml" xpointer="xmlns(d=http://docbook.org/ns/docbook) xpointer(/d:article/d:section/*)"/>
+</section>
 <section xml:id="V1.79.1">
 <title>Release Notes: 1.79.1</title>
 <para>The following is a list of changes that have been made