SVN commit 1220053 by pino: upate the changelog.xsl to support gitweb links
kind of abstract the "web $vcs" name and link generation, deducing the repository type from the revision string: - less than 7 chars, svn - 40 chars, git additionally, introduce a new "reponame" attribute for "module", "product", and "component" tags, to allow setting the repository name (the most specific one wins); if not specified, the default behaviour is to use the component or product name. should hopefully not break anything, in case just let me know CCMAIL: kde-core-devel@kde.org M +3 -3 DOCS M +5 -1 changelog.dtd M +97 -5 changelog.xsl --- trunk/www/sites/www/announcements/changelogs/DOCS #1220052:1220053 @@ -53,13 +53,13 @@ Divisions --------- -<module name=""> +<module name="" [reponame=""]> An SVN module. If possible, make sure the lowercase form of the "name" attribute is the exact name of the module in SVN (this makes the 'rev' attribute work - see below). -<product name="" [homepage=""]> +<product name="" [homepage=""] [reponame=""]> An application or other component which forms the toplevel in an SVN module. Again, make sure that the lowercase form of the name attribute is as it appears in SVN if you want the 'rev' attribute to work. The homepage attribute is an optional URL of the product's homepage. -<component name=""> +<component name="" [reponame=""]> A component within a <product>. Change types --- trunk/www/sites/www/announcements/changelogs/changelog.dtd #1220052:1220053 @@ -15,6 +15,7 @@ <!ELEMENT module (product*)> <!ATTLIST module name CDATA #REQUIRED homepage CDATA #IMPLIED + reponame CDATA #IMPLIED > <!-- The product is the element representing your application / library. @@ -29,11 +30,14 @@ <!ELEMENT product (component|bugfix|feature|improvement|optimize)+> <!ATTLIST product name CDATA #REQUIRED homepage CDATA #IMPLIED + reponame CDATA #IMPLIED > <!-- Used to group bugfixes/features inside an application / library. --> <!ELEMENT component (bugfix|feature|improvement|optimize)+> -<!ATTLIST component name CDATA #REQUIRED> +<!ATTLIST component name CDATA #REQUIRED + reponame CDATA #IMPLIED +> <!-- Describes a bugfix entry. rev: SVN revision number, eventually seperated by spaces. --- trunk/www/sites/www/announcements/changelogs/changelog.xsl #1220052:1220053 @@ -183,16 +183,48 @@ beforehand. --> <xsl:if test="@rev != ''"> - <xsl:variable name="thesvnpath"> - <xsl:call-template name="svnpath"/> + <xsl:variable name="reponame"> + <xsl:choose> + <xsl:when test="@reponame != ''"> + <xsl:value-of select="@reponame"/> + </xsl:when> + <xsl:when test="ancestor::component[last()]/@reponame != ''"> + <xsl:value-of select="ancestor::component[last()]/@reponame"/> + </xsl:when> + <xsl:when test="ancestor::product[last()]/@reponame != ''"> + <xsl:value-of select="ancestor::product[last()]/@reponame"/> + </xsl:when> + <xsl:when test="ancestor::module[last()]/@reponame != ''"> + <xsl:value-of select="ancestor::module[last()]/@reponame"/> + </xsl:when> + <xsl:when test="count(ancestor::component) != 0"> + <xsl:value-of select="ancestor::component[last()]/@name"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="ancestor::product[last()]/@name"/> + </xsl:otherwise> + </xsl:choose> </xsl:variable> <xsl:for-each select="str:split(@rev, ' ')"> + <xsl:variable name="thevcstype"> + <xsl:call-template name="vcstype"> + <xsl:with-param name="rev"><xsl:value-of select="."/></xsl:with-param> + </xsl:call-template> + </xsl:variable> <xsl:choose> <xsl:when test="last() = 1"> - <xsl:text> See SVN commit </xsl:text> + <xsl:text> See </xsl:text> + <xsl:call-template name="vcsname"> + <xsl:with-param name="vcstype"><xsl:value-of select="$thevcstype"/></xsl:with-param> + </xsl:call-template> + <xsl:text> commit </xsl:text> </xsl:when> <xsl:when test="position() = 1"> - <xsl:text> See SVN commits </xsl:text> + <xsl:text> See </xsl:text> + <xsl:call-template name="vcsname"> + <xsl:with-param name="vcstype"><xsl:value-of select="$thevcstype"/></xsl:with-param> + </xsl:call-template> + <xsl:text> commits </xsl:text> </xsl:when> <xsl:when test="position() != last()"> <xsl:text>, </xsl:text> @@ -201,7 +233,10 @@ <xsl:text> and </xsl:text> </xsl:otherwise> </xsl:choose> - <a href="{$thesvnpath}/?rev={.}&view=rev"><xsl:value-of select="."/></a> + <xsl:call-template name="vcspath"> + <xsl:with-param name="vcstype"><xsl:value-of select="$thevcstype"/></xsl:with-param> + <xsl:with-param name="reponame"><xsl:value-of select="$reponame"/></xsl:with-param> + </xsl:call-template> </xsl:for-each> <xsl:text>. </xsl:text> </xsl:if> @@ -230,5 +265,62 @@ </xsl:if> </xsl:template> + <xsl:template name="vcstype"> + <xsl:param name="rev"/> + <xsl:choose> + <xsl:when test="string-length($rev) <= 7">svn</xsl:when> + <xsl:when test="string-length($rev) = 40">git</xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + Unknown VCS for commit '<xsl:value-of select="$rev"/>'! + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="vcsname"> + <xsl:param name="vcstype"/> + <xsl:choose> + <xsl:when test="$vcstype = 'svn'">SVN</xsl:when> + <xsl:when test="$vcstype = 'git'">Git</xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + Unknown VCS type '<xsl:value-of select="$vcstype"/>'! + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="vcspath"> + <xsl:param name="vcstype"/> + <xsl:param name="reponame"/> + <xsl:choose> + <xsl:when test="$vcstype = 'svn'"> + <xsl:variable name="thesvnpath"> + <xsl:call-template name="svnpath"/> + </xsl:variable> + <a href="{$thesvnpath}/?rev={.}&view=rev"><xsl:value-of select="."/></a> + </xsl:when> + <xsl:when test="$vcstype = 'git'"> + <xsl:variable name="thegitpath"> + <xsl:call-template name="gitpath"/> + </xsl:variable> + <xsl:if test="$reponame = ''"> + <xsl:message terminate="yes"> + Git commit <xsl:value-of select="$rev"/> without 'reponame' attribute! + </xsl:message> + </xsl:if> + <a href="{$thegitpath}/{$reponame}/{.}"><xsl:value-of select="substring(.,1,7)"/></a> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + Unknown VCS type '<xsl:value-of select="$vcstype"/>'! + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template name="svnpath">http://websvn.kde.org</xsl:template> + <xsl:template name="gitpath">http://commits.kde.org</xsl:template> + </xsl:stylesheet>