Am 25.02.20 um 10:22 schrieb Felix Schumacher: > Am 24.02.2020 22:13, schrieb Christopher Schultz: > Mark, > > On 2/24/20 15:46, Mark Thomas wrote: > >>> On 24/02/2020 20:31, Christopher Schultz wrote: > >>>> Mark, > >>> > >>>> Why not use the full commit id instead of a prefix? Couldn't > >>>> some future commit conflict with some arbitrary prefix? Or do I > >>>> not know what the hell I'm talking about? > >>> > >>> No, you are spot on. The reason I used the prefix is that I was > >>> transcribing the commit IDs by hand so the prefixes were easier. > >>> We probably should use the full ID or at least a longer prefix. > > I wonder if we could script this: grab a prefix, find the (one and > only one) commit in the repo and expand it. If there is a conflict (or > more than one match), emit an error and continue without changing the > commit id. > > When I do this kind of thing for $work, I like to write scripts that > emit sed scripts. So you process e.g. security-8.html as input, but > emit something like this as output: > > s/(\b)69c5608(\b)/\169c56080fb3355507e1b55d014ec0ee6767a6150\2/g > ... > > You get a script that can be inspected, re-used and, even better, it > doesn't directly modify the input files. So you can even do something > like this: > > $ expand-git-commit-ids.pl security-*.xml > expand.sed > > $ sed -i .bak -f expand.sed security-*.xml > > And then if you find other files where the same kind of thing needs to > be done, you can re-use the expand.sed script, or even (pun intended) > expand the sed script if necessary. > > > I would use the full hash in the xml and use a substring-function in > the xsl to shorten the hash for readability. > > > No need for sed here :)
Now - that I re-read Chris answer - I see what he had in mind. I think we can combine the two things. First use a script to convert the hashes to the full version and second, adapt the xslt to emit a shorter version for the text of the link. perl -M5.020 -ne 'say $1 if /hashlink hash="(\w+)"/' ../tomcat-site-trunk/xdocs/security-9.xml | while read i; do git log --pretty="s/\\b$i\\b/%H/g" -l 1 $i^1..$i | cat; done That would generate the sed script for security-9.xml And Index: xdocs/stylesheets/tomcat-site.xsl =================================================================== --- xdocs/stylesheets/tomcat-site.xsl (Revision 1874497) +++ xdocs/stylesheets/tomcat-site.xsl (Arbeitskopie) @@ -359,7 +359,7 @@ <!-- Link to a git hash --> <xsl:template match="hashlink"> <xsl:variable name="link"><xsl:value-of select="$hashlink"/><xsl:value-of select="@hash"/></xsl:variable> - <a href="{$link}"><xsl:apply-templates/></a> + <a href="{$link}"><xsl:value-of select="substring(@hash, 0, 9)"/></a> </xsl:template> <!-- Link to a CVE report --> would take care of using the substring for the text. We would loose the ability to use arbitrary text in the link, but it wasn't used anyway. Felix > > > Felix > > > -chris >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: dev-h...@tomcat.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org