Flux RSS des modifications SVN

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Inscription: Fév 10, 2004
  • Messages: 13455
  • Loc: Florida
  • Status: Offline

Message Octobre 16th, 2010, 4:38 am

Im va commencer à faire mon journal SVN à la disposition du public et je cherche des idées.

Le serveur SVN est ici à la maison, et le site Web public est hébergé sur un site distant. Que penser Im en faisant le met en place une tâche cron / script qui démarre en exportant le journal SVN.

Code: [ Select ]
$ svn log > changelog.log


Je veux faire tout le journal disponible pour ceux qui le veulent, mais pas comme un flux RSS. Donc, après l'exportation du journal, Im pensant Ill il gzip tout de suite. Je ne veux pas de diriger la sortie de la décharge se connecter directement par le biais de goudron parce que je veux ouvrir le dump et travailler avec elle.

Code: [ Select ]
$ tar --gzip -cf changelog.tar.gz changelog.log


Suivant Im pensant changelog.log analyser Ill jusqu'à ce que j'aie des 10 dernières révisions stockées dans un tableau. Une fois que j'ai, je peux générer un flux RSS et à sauver cette changelog.tar.gz que changelog.xml et une fois que j'ai et je peux les changelog.xml SCP sur le serveur public avant de supprimer le changelog. log

Avant d'écrire quelque chose à faire cette analyse, j'ai pensé que sa vaut le détour si quelqu'un a quelque chose comme ça déjà, ou peut-être une meilleure idée. :)
Strong with this one, the sudo is.
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Octobre 16th, 2010, 4:38 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Inscription: Fév 10, 2004
  • Messages: 13455
  • Loc: Florida
  • Status: Offline

Message Octobre 16th, 2010, 5:38 pm

Je suis tombé sur ce blog , À partir de Septembre 2006 et il ressemble à son assez facile d'exporter le journal en format XML et de le transformer avec XSL.

Appare notly le lien aux auteurs de la transformation XSLT est mort. Heureusement, un commentaire de Mars 2009 a eu un lien de travail où j'ai pu obtenir le xslt.

Pour la plupart, il a travaillé dès la sortie de la boîte. Certains d'entre le code HTML utilisé dans le xslt est un peu daté mais si j'ai fait un nettoyage quelques minuscules. Par exemple, je suis passé d'un <table> pour la liste des fichiers modifiés à une <ul> avec <abbr> utilisé pour les actions au lieu de les énonçant.

En ce moment Im en utilisant la commande suivante pour exporter des 10 dernières révisions du journal SVN, le "-v" peut être enlevé lorsque la liste des fichiers modifiés n'est pas voulu.

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


Le blog a un exemple d'un système Windows, mais depuis mon serveur SVN est sur un serveur Linux et c'est là que la tâche cron sera en cours d'exécution, j'ai ce pour faire la transformation.

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


De là, je peux soit également exporter mon journal complet compressé puis rsync le répertoire avec le serveur distant, ou prendre le temps de tout tuyau autour donc je ne peux éviter de fichiers intermédiaires. Ill de cela plus tard, mais j'ai un sentiment Im vais aller avec rsync.

Heres ma version mise à jour de svnlog.xslt

XML Code: [ 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
  • Inscription: Fév 10, 2004
  • Messages: 13455
  • Loc: Florida
  • Status: Offline

Message Octobre 18th, 2010, 10:00 pm

Avec les trucs que j'ai appris dans mon dernier post, Ive été d'utiliser ce petit script shell pour les deux derniers jours, laissant cron l'exécuter une fois par jour, et sa fonctionne très bien été.

J'ai en effet fini par aller avec rsync.

Ive a obtenu ce script dans un répertoire avec un sous-répertoire appelé "logs" et la xslt de mon dernier message. Je me retrouve avec un "rss.xml" et un "archive.tar.gz" dans le répertoire / changelog / répertoire de l'hôte distant.

BASH Code: [ 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.

Afficher de l'information

  • Total des messages de ce sujet: 3 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 191 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC