RSS de SVN Changelog

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13455
  • Loc: Florida
  • Status: Offline

Nota Octubre 16th, 2010, 4:38 am

Voy a empezar a hacer mi registro de SVN a disposición del público y estoy en busca de ideas.

El servidor de SVN es aquí en casa, y el sitio web público se encuentra alojado en una ubicación remota. Lo que estoy pensando en hacer es la creación de una tarea de cron / script que comienza con la exportación en el registro de SVN.

Código: [ Select ]
$ svn log > changelog.log


Quiero hacer todo el registro disponible para aquellos que lo quieren, pero no como un canal RSS. Así que después de exportar el registro, estoy pensando en la enfermedad lo gzip de inmediato. No quiero dirigir la salida del volcado de registro directamente a través de alquitrán, porque quiero abrir el vertedero y trabajar con ella.

Código: [ Select ]
$ tar --gzip -cf changelog.tar.gz changelog.log


A continuación estoy pensando changelog.log enfermedad analizar hasta que tenga los últimos 10 revisiones almacenados en una matriz. Una vez que tenga eso, puede generar un feed RSS y salvamento de dicha changelog.tar.gz como changelog.xml y una vez que tengo y puedo changelog.xml SCP al servidor público antes de eliminar de cambios. registro

Antes de escribir algo que ver este análisis, me di cuenta de su vale la pena ver si alguien tiene algo parecido a esto ya, o tal vez una mejor idea. :)
Strong with this one, the sudo is.
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Octubre 16th, 2010, 4:38 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13455
  • Loc: Florida
  • Status: Offline

Nota Octubre 16th, 2010, 5:38 pm

Me encontré con esta entrada de blog , A partir de septiembre de 2006 y parece que su bastante fácil de exportar el registro en formato XML y transformarlo con XSL.

Appare notly el enlace de los autores a la xslt está muerto. Por suerte un comentario a partir de marzo de 2009 había un vínculo de trabajo donde tuve la oportunidad de obtener el xslt.

En su mayor parte, funcionó a la derecha de la caja. Algunos de los HTML que se utiliza en el xslt es un poco anticuado, aunque así que hice una pequeña limpieza de unos pocos. Por ejemplo, me cambié de un <table> por la publicación de archivos alterados a un <ul> con <abbr> utilizado para las acciones en lugar de la ortografía a cabo.

En este momento estoy usando el siguiente comando para exportar el 10 últimas revisiones del registro de SVN, la opción "-v" switch puede ser removido cuando la lista de archivos alterados no se desea.

Código: [ Select ]
$ svn -v --xml --limit 10 log svn+ssh://localhost/path/to/repo > /path/to/log.xml


El blog tiene un ejemplo de un sistema Windows, pero desde mi servidor SVN está en un servidor Linux y que es donde el trabajo de cron va a correr, tengo esto para hacer la transformación.

Código: [ Select ]
$ xsltproc /path/to/svnlog.xslt /path/to/log.xml > /path/to/changelog.xml


Desde aquí puede o también exportar mi registro gzip completa a continuación, rsync el directorio con el servidor remoto, o tomar el tiempo para todo lo que alrededor de la tubería para que pueda evitar los archivos intermedios. Enfermedad consigue a eso más adelante, pero tengo la sensación Im que va a ir con rsync.

Aquí está mi versión actualizada de svnlog.xslt

XML Código: [ Select ]
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" extension-element-prefixes="date func str" version="1.0">
 
   <xsl:output omit-xml-declaration="no" indent="yes" encoding="UTF-8" method="xml" />    
   
   <xsl:template match="log">
     <rss version="2.0">
         <channel>
            <title>RSS Feed Title</title>
            <link>http://domain.com/</link>
            <description>RSS Description</description>
            <language>en-us</language>
            <copyright>Compant Name</copyright>
            <xsl:apply-templates select="logentry" />
         </channel>
     </rss>
   </xsl:template>
   
   <xsl:template match="logentry">
     <item>
         <title>Revision <xsl:value-of select="@revision"/></title>
         <pubDate><xsl:call-template name="rfc822"><xsl:with-param name="isodate" select="date" /></xsl:call-template></pubDate>
         <author><xsl:value-of select="author" />@domain.com</author>
         <description disable-output-escaping="yes">
            &lt;pre&gt;<xsl:value-of select="msg" />&lt;/pre&gt;
            &lt;ul style="font-size:small;"&gt;<xsl:apply-templates select="paths/path" />&lt;/ul&gt;
         </description>
     </item>
   </xsl:template>
       
   <xsl:template match="paths/path">
      &lt;li&gt;&lt;strong&gt;<xsl:call-template name="svncommand"><xsl:with-param name="command" select="@action" /></xsl:call-template>&lt;/strong&gt;&amp;nbsp;<xsl:value-of select="."/>&lt;/li&gt;
   </xsl:template>
 
   <xsl:template name="rfc822">
      <xsl:param name="isodate" />
      <xsl:variable name="dayOfWeek" select="date:day-abbreviation($isodate)" />
      <xsl:variable name="day" select="date:day-in-month($isodate)" />
      <xsl:variable name="monthAbbr" select="date:month-abbreviation($isodate)" />
      <xsl:variable name="year" select="date:year($isodate)" />
      <xsl:variable name="hour" select="date:hour-in-day($isodate)" />
      <xsl:variable name="minute" select="date:minute-in-hour($isodate)" />
      <xsl:variable name="second" select="round(date:second-in-minute($isodate))" />
 
      <xsl:value-of select="$dayOfWeek" />
      <xsl:text>, </xsl:text>
      <xsl:value-of select="$day" />
      <xsl:text> </xsl:text>
      <xsl:value-of select="$monthAbbr" />
      <xsl:text> </xsl:text>
      <xsl:value-of select="$year" />
      <xsl:choose>
         <xsl:when test="$hour and $minute and $second">
            <xsl:text> </xsl:text>
            <xsl:value-of select="str:align($hour, '00', 'right')" />
            <xsl:text>:</xsl:text>
            <xsl:value-of select="str:align($minute, '00', 'right')" />
            <xsl:text>:</xsl:text>
            <xsl:value-of select="str:align($second, '00', 'right')" />
            <xsl:text> GMT</xsl:text>
         </xsl:when>
         <xsl:otherwise>
            <xsl:text> 00:00:00 GMT</xsl:text>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   <xsl:template name="svncommand">
      <xsl:param name="command"/>
      <xsl:choose>
         <xsl:when test="$command = 'A'">&lt;abbr title="Added"&gt;A&lt;/abbr&gt;</xsl:when>
         <xsl:when test="$command = 'D'">&lt;abbr title="Deleted"&gt;D&lt;/abbr&gt;</xsl:when>
         <xsl:when test="$command = 'M'">&lt;abbr title="Modified"&gt;M&lt;/abbr&gt;</xsl:when>
      </xsl:choose>
   </xsl:template>
 
<!--
svnlog.xslt by Martin Pittenauer / TheCodingMonkeys        
Web: www.codingmonkeys.de, Mail: map@codingmonkeys.de                              
 
iso->rfc822 date conversion code heavily inspired by Steven Engelhardt (http://www.deez.info/sengelha/)
Tested with libxslt.
 
HTML brought up to date (Oct 2010) by Joe Kovar
http://www.ozzu.com/programming-forum/rss-feed-svn-changelog-t104499.html
-->
 
</xsl:stylesheet>
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:func="http://exslt.org/functions" xmlns:str="http://exslt.org/strings" extension-element-prefixes="date func str" version="1.0">
  3.  
  4.    <xsl:output omit-xml-declaration="no" indent="yes" encoding="UTF-8" method="xml" />    
  5.    
  6.    <xsl:template match="log">
  7.      <rss version="2.0">
  8.          <channel>
  9.             <title>RSS Feed Title</title>
  10.             <link>http://domain.com/</link>
  11.             <description>RSS Description</description>
  12.             <language>en-us</language>
  13.             <copyright>Compant Name</copyright>
  14.             <xsl:apply-templates select="logentry" />
  15.          </channel>
  16.      </rss>
  17.    </xsl:template>
  18.    
  19.    <xsl:template match="logentry">
  20.      <item>
  21.          <title>Revision <xsl:value-of select="@revision"/></title>
  22.          <pubDate><xsl:call-template name="rfc822"><xsl:with-param name="isodate" select="date" /></xsl:call-template></pubDate>
  23.          <author><xsl:value-of select="author" />@domain.com</author>
  24.          <description disable-output-escaping="yes">
  25.             &lt;pre&gt;<xsl:value-of select="msg" />&lt;/pre&gt;
  26.             &lt;ul style="font-size:small;"&gt;<xsl:apply-templates select="paths/path" />&lt;/ul&gt;
  27.          </description>
  28.      </item>
  29.    </xsl:template>
  30.        
  31.    <xsl:template match="paths/path">
  32.       &lt;li&gt;&lt;strong&gt;<xsl:call-template name="svncommand"><xsl:with-param name="command" select="@action" /></xsl:call-template>&lt;/strong&gt;&amp;nbsp;<xsl:value-of select="."/>&lt;/li&gt;
  33.    </xsl:template>
  34.  
  35.    <xsl:template name="rfc822">
  36.       <xsl:param name="isodate" />
  37.       <xsl:variable name="dayOfWeek" select="date:day-abbreviation($isodate)" />
  38.       <xsl:variable name="day" select="date:day-in-month($isodate)" />
  39.       <xsl:variable name="monthAbbr" select="date:month-abbreviation($isodate)" />
  40.       <xsl:variable name="year" select="date:year($isodate)" />
  41.       <xsl:variable name="hour" select="date:hour-in-day($isodate)" />
  42.       <xsl:variable name="minute" select="date:minute-in-hour($isodate)" />
  43.       <xsl:variable name="second" select="round(date:second-in-minute($isodate))" />
  44.  
  45.       <xsl:value-of select="$dayOfWeek" />
  46.       <xsl:text>, </xsl:text>
  47.       <xsl:value-of select="$day" />
  48.       <xsl:text> </xsl:text>
  49.       <xsl:value-of select="$monthAbbr" />
  50.       <xsl:text> </xsl:text>
  51.       <xsl:value-of select="$year" />
  52.       <xsl:choose>
  53.          <xsl:when test="$hour and $minute and $second">
  54.             <xsl:text> </xsl:text>
  55.             <xsl:value-of select="str:align($hour, '00', 'right')" />
  56.             <xsl:text>:</xsl:text>
  57.             <xsl:value-of select="str:align($minute, '00', 'right')" />
  58.             <xsl:text>:</xsl:text>
  59.             <xsl:value-of select="str:align($second, '00', 'right')" />
  60.             <xsl:text> GMT</xsl:text>
  61.          </xsl:when>
  62.          <xsl:otherwise>
  63.             <xsl:text> 00:00:00 GMT</xsl:text>
  64.          </xsl:otherwise>
  65.       </xsl:choose>
  66.    </xsl:template>
  67.    
  68.    <xsl:template name="svncommand">
  69.       <xsl:param name="command"/>
  70.       <xsl:choose>
  71.          <xsl:when test="$command = 'A'">&lt;abbr title="Added"&gt;A&lt;/abbr&gt;</xsl:when>
  72.          <xsl:when test="$command = 'D'">&lt;abbr title="Deleted"&gt;D&lt;/abbr&gt;</xsl:when>
  73.          <xsl:when test="$command = 'M'">&lt;abbr title="Modified"&gt;M&lt;/abbr&gt;</xsl:when>
  74.       </xsl:choose>
  75.    </xsl:template>
  76.  
  77. <!--
  78. svnlog.xslt by Martin Pittenauer / TheCodingMonkeys        
  79. Web: www.codingmonkeys.de, Mail: map@codingmonkeys.de                              
  80.  
  81. iso->rfc822 date conversion code heavily inspired by Steven Engelhardt (http://www.deez.info/sengelha/)
  82. Tested with libxslt.
  83.  
  84. HTML brought up to date (Oct 2010) by Joe Kovar
  85. http://www.ozzu.com/programming-forum/rss-feed-svn-changelog-t104499.html
  86. -->
  87.  
  88. </xsl:stylesheet>
Strong with this one, the sudo is.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13455
  • Loc: Florida
  • Status: Offline

Nota Octubre 18th, 2010, 10:00 pm

Con las cosas que aprendí en mi último post, he estado utilizando este script de shell poco en el último par de días, dejando que cron lo ejecute una vez al día, y su estado trabajando muy bien.

Yo a la verdad terminó yendo con rsync.

Ive consiguió este script en un directorio junto con un sub-directorio llamado "logs" y la xslt desde mi último post. Termino con una "rss.xml" y un "archivo.tar.gz" en el directorio / registros de cambios / del host remoto.

BASH Código: [ Select ]
#!/bin/bash
 
REPO_URL="http://localhost/svn/repo"
CRON_PATH="/this/files/directory"
ARCHIVE_NAME="archive.tar.gz"
RSS_NAME="rss.xml"
 
XML_PATH="$CRON_PATH/svnlog.xml"
XSLT_PATH="$CRON_PATH/svnlog-to-rss.xslt"
RSS_PATH="$CRON_PATH/logs/$RSS_NAME"
GZ_PATH="$CRON_PATH/logs/$ARCHIVE_NAME"
LOG_NAME="changelog.log"
LOG_PATH="$CRON_PATH/$LOG_NAME"
 
svn -v --xml --limit 10 log "$REPO_URL" > "$XML_PATH"
xsltproc "$XSLT_PATH" "$XML_PATH" > "$RSS_PATH"
 
svn -v log "$REPO_URL" > "$LOG_PATH"
tar --gzip -cf "$GZ_PATH" -C "$CRON_PATH" "$LOG_NAME"
 
rm $XML_PATH $LOG_PATH
 
rsync -qcah --rsh="ssh -i'/path/to/.ssh/key'" "$CRON_PATH/logs/" me@remote.com:/home/me/changelogs/
 
  1. #!/bin/bash
  2.  
  3. REPO_URL="http://localhost/svn/repo"
  4. CRON_PATH="/this/files/directory"
  5. ARCHIVE_NAME="archive.tar.gz"
  6. RSS_NAME="rss.xml"
  7.  
  8. XML_PATH="$CRON_PATH/svnlog.xml"
  9. XSLT_PATH="$CRON_PATH/svnlog-to-rss.xslt"
  10. RSS_PATH="$CRON_PATH/logs/$RSS_NAME"
  11. GZ_PATH="$CRON_PATH/logs/$ARCHIVE_NAME"
  12. LOG_NAME="changelog.log"
  13. LOG_PATH="$CRON_PATH/$LOG_NAME"
  14.  
  15. svn -v --xml --limit 10 log "$REPO_URL" > "$XML_PATH"
  16. xsltproc "$XSLT_PATH" "$XML_PATH" > "$RSS_PATH"
  17.  
  18. svn -v log "$REPO_URL" > "$LOG_PATH"
  19. tar --gzip -cf "$GZ_PATH" -C "$CRON_PATH" "$LOG_NAME"
  20.  
  21. rm $XML_PATH $LOG_PATH
  22.  
  23. rsync -qcah --rsh="ssh -i'/path/to/.ssh/key'" "$CRON_PATH/logs/" me@remote.com:/home/me/changelogs/
  24.  
Strong with this one, the sudo is.

Publicar Información

  • Total de mensajes en este tema: 3 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 193 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC