Last active
August 29, 2015 13:58
-
-
Save soyo42/10141622 to your computer and use it in GitHub Desktop.
refine bugzilla xml-dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "usage:: $0 <bugId> [<bugId> [<bugId> ...]]" | |
exit 1 | |
fi | |
refineRoot="$(dirname "$(readlink -f "$0")")" | |
tStamp="$(date +'%Y%m%d-%H%M%S')" | |
idList= | |
for id in $@; do | |
idList="${idList}id=${id}&" | |
done | |
echo "${idList}" >&2 | |
out="${tStamp}-tmp.xml" | |
wget -O "${out}" "https://bugs.opendaylight.org/show_bug.cgi?${idList}&ctype=xml&excludefield=attachmentdata" | |
xsltproc ${refineRoot}/refineBz.xslt "${out}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="text"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:variable name='dlm'><xsl:text>,</xsl:text></xsl:variable> | |
<xsl:variable name='quot'><xsl:text>"</xsl:text></xsl:variable> | |
<xsl:variable name='newline'><xsl:text> | |
</xsl:text></xsl:variable> | |
<xsl:template match="/"> | |
<xsl:text>bugId, product, assigned_to, bug_status, short_desc, severity, priority, depends, blocked, resolution, changed, component, reporter, comments | |
</xsl:text> | |
<xsl:apply-templates select="//bug"/> | |
</xsl:template> | |
<xsl:template match="bug"> | |
<!-- <xsl:apply-templates select="./bug_id"/> --> | |
<xsl:value-of select="./bug_id/text()" /> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./product/text()" mode="anyText" /> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./assigned_to/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./bug_status/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./short_desc/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./bug_severity/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./priority" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<!-- depends on --> | |
<xsl:apply-templates select="." mode="depends"/> | |
<!-- blocked by --> | |
<xsl:apply-templates select="." mode="blocked"/> | |
<xsl:apply-templates select="./resolution/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./delta_ts/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./component/text()" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<xsl:apply-templates select="./reporter/@name" mode="anyText"/> | |
<xsl:value-of select="$dlm" /> | |
<!-- amount of comments --> | |
<xsl:value-of select="count(.//commentid)" /> | |
<xsl:value-of select="$newline" /> | |
</xsl:template> | |
<xsl:template mode="anyText" match="text()|@*"> | |
<xsl:value-of select="concat($quot, ., $quot)" /> | |
</xsl:template> | |
<xsl:template mode="depends" match="//bug"> | |
<xsl:text>D[</xsl:text> | |
<xsl:for-each select="./dependson"> | |
<xsl:value-of select="concat(./text(), ' ')"/> | |
</xsl:for-each> | |
<xsl:value-of select="concat(']', $dlm)" /> | |
</xsl:template> | |
<xsl:template mode="blocked" match="//bug"> | |
<xsl:text>B[</xsl:text> | |
<xsl:for-each select="./blocked"> | |
<xsl:value-of select="concat(./text(), ' ')"/> | |
</xsl:for-each> | |
<xsl:value-of select="concat(']', $dlm)" /> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment