SVN et Changelog.

ViPHP
ViPHP | 4674 Messages

28 juin 2008, 19:29

Hey :),

Ça fait un moment que je regardais ce qu'il se faisait sur le net, et rien ne me plaisait, alors j'ai fait mon petite script à l'instant. Le résultat est pas trop mal, alors, hop, on partage ;-).
L'idée est de produire un changelog à partir d'un dépôt SVN. Mieux encore, je voulais un changelog pour un dossier particulier d'un dépôt SVN.

J'ai laissé les valeurs de mes variables pour rendre la chose plus clair. En gros, on a le dépôt (repository) /Users/hywan/Svn/Hoa/Repository/, et dans ce dépôt, on veut faire un changelog du dossier Project/Framework/Trunk/Framework (oui, dans Trunk on a Bin et Framework). Le changelog produit sera à l'emplace /Users/hywan/Sites/Hoa/Project/Framework/Trunk/CHANGELOG, talaa.

Voici le script :

Code : Tout sélectionner

#!/bin/sh ### # Hoa Framework # # # @license # # GNU General Public License # # This file is part of HOA Open Accessibility. # Copyright (c) 2007, 2008 Ivan ENDERLIN. All rights reserved. # # HOA Open Accessibility is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # HOA Open Accessibility is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with HOA Open Accessibility; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ### ### # Changelog.sh # # Build a changelog from a specific folder of a repository. # # @author Ivan ENDERLIN <[email protected]> # @copyright Copyright (c) 2008 Ivan ENDERLIN. # @license http://gnu.org/licenses/gpl.txt GNU GPL # @version 0.1 ## repos="/Users/hywan/Svn/Hoa/Repository/" in="Project/Framework/Trunk/Framework/" cl="/Users/hywan/Sites/Hoa/Project/Framework/Trunk/CHANGELOG" youngest=0 > $cl echo " Changelog of Hoa Framework\n" \ " # *************************\n\n\n" \ "Informations :\n" \ " - repository path : $repos\n" \ " - path in repository : $in\n" \ " - generated at : "`date +%d/%m/%Y\ %R:%S` >> $cl echo "\n\n" >> $cl for rev in `svnlook history $repos $in | cut -f1 -d/`; do if [ "`echo $rev | grep -E "^[0-9]+$"`" != "" ]; then if [ $rev -gt $youngest ]; then youngest=$rev fi if [ $rev -ne 1 ]; then head="Rev. $rev :\c" echo $head >> $cl let n=16-${#head} while test $n -gt 0; do echo " \c" >> $cl let n=n-1 done echo `svnlook log $repos -r $rev` >> $cl echo " At \c" >> $cl echo `svnlook date $repos -r $rev` >> $cl echo " By \c" >> $cl echo `svnlook author $repos -r $rev` >> $cl for e in `svnlook changed $repos -r $rev`; do case "$e" in "A") echo " Added \c" >> $cl ;; "D") echo " Deleted \c" >> $cl ;; "U") echo " Updated \c" >> $cl ;; "C") echo " Conflict \c" >> $cl ;; "G") echo " Merged \c" >> $cl ;; *) echo ${e#$in*} >> $cl ;; esac done; echo "\n" >> $cl fi fi done echo "\n\n\n" >> $cl echo " Project tree\n" \ " (at the youngest revision)\n" \ " # *************************\n" >> $cl svnlook tree -r $youngest $repos $in >> $cl
Le résultat ressemble à :

Code : Tout sélectionner

Changelog of Hoa Framework ************************** Informations : - repository path : /Users/hywan/Svn/Hoa/Repository/ - path in repository : Project/Framework/Trunk/Framework/ - generated at : 28/06/2008 19:02:05 Rev. 97 : Useless package, just a test. At 2008-06-28 18:57:13 +0200 (Sam, 28 jui 2008) By hywan Deleted Bin/ Rev. 95 : Add the auto-complete with the method attribute value data array support. At 2008-06-28 16:18:18 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Form.php Rev. 94 : Add the auto-complete with the method attribute value data array support. At 2008-06-28 16:15:39 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Form.php Rev. 93 : Cleaning. At 2008-06-28 16:06:25 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Form.php Rev. 92 : Cleaning. At 2008-06-28 15:47:50 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Decorator/Abstract.php Updated Form/Decorator/Fieldset.php Updated Form/Decorator/InputButton.php Updated Form/Decorator/InputCheckbox.php Updated Form/Decorator/InputFile.php Updated Form/Decorator/InputHidden.php Updated Form/Decorator/InputImage.php Updated Form/Decorator/InputPassword.php Updated Form/Decorator/InputRadio.php Updated Form/Decorator/InputReset.php Updated Form/Decorator/InputSubmit.php Updated Form/Decorator/InputText.php Updated Form/Decorator/Select.php Updated Form/Decorator/SelectOptgroup.php Updated Form/Decorator/SelectOption.php Updated Form/Decorator/Textarea.php Rev. 91 : Cleaning. At 2008-06-28 15:23:28 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Decorator/Abstract.php Updated Form/Decorator/Fieldset.php Updated Form/Decorator/InputButton.php Updated Form/Decorator/InputCheckbox.php Updated Form/Decorator/InputFile.php Updated Form/Decorator/InputHidden.php Updated Form/Decorator/InputImage.php Updated Form/Decorator/InputPassword.php Updated Form/Decorator/InputRadio.php Updated Form/Decorator/InputReset.php Updated Form/Decorator/InputSubmit.php Updated Form/Decorator/InputText.php Updated Form/Decorator/Select.php Updated Form/Decorator/SelectOptgroup.php Updated Form/Decorator/SelectOption.php Updated Form/Decorator/Textarea.php Rev. 90 : Cleaning. At 2008-06-28 15:19:33 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Element/Abstract.php Updated Form/Element/Form.php Updated Form/Element/Select.php Updated Form/Element/SelectOptgroup.php Rev. 89 : Cleaning. At 2008-06-28 15:12:14 +0200 (Sam, 28 jui 2008) By hywan Updated Form/Element/InputHidden.php Updated Form/Element/InputImage.php Updated Form/Element/InputPassword.php Updated Form/Element/InputRadio.php Updated Form/Element/InputReset.php Updated Form/Element/InputSubmit.php Updated Form/Element/Label.php Updated Form/Element/Legend.php Updated Form/Element/Select.php Updated Form/Element/SelectOptgroup.php Updated Form/Element/SelectOption.php Updated Form/Element/Textarea.php Rev. 87 : Cleaning At 2008-06-27 16:43:23 +0200 (Ven, 27 jui 2008) By hywan Updated Form/Element/InputButton.php Updated Form/Element/InputCheckbox.php Updated Form/Element/InputFile.php Updated Form/Element/InputHidden.php Updated Form/Element/InputImage.php Updated Form/Element/InputPassword.php Updated Form/Element/InputRadio.php Updated Form/Element/InputReset.php Updated Form/Element/InputSubmit.php Updated Form/Element/InputText.php Updated Form/Element/Label.php Updated Form/Element/Legend.php Updated Form/Element/Select.php Updated Form/Element/SelectOptgroup.php Updated Form/Element/SelectOption.php Updated Form/Element/Textarea.php Rev. 86 : Cleaning. At 2008-06-27 16:14:41 +0200 (Ven, 27 jui 2008) By hywan Updated Form/Element/Form.php Rev. 85 : Cleaning. At 2008-06-27 14:13:35 +0200 (Ven, 27 jui 2008) By hywan Updated Form/Element/Fieldset.php Rev. 84 : Cleaning. At 2008-06-27 12:53:11 +0200 (Ven, 27 jui 2008) By hywan Updated Form/Element/Abstract.php Rev. 83 : Add the __DIR__ constant for PHP < 5.3 At 2008-06-27 12:15:32 +0200 (Ven, 27 jui 2008) By hywan Updated Framework.php Rev. 80 : Edit the error output. At 2008-06-26 17:17:59 +0200 (Jeu, 26 jui 2008) By hywan Updated Validate/Array.php Rev. 79 : Correct a bug. At 2008-06-26 17:03:01 +0200 (Jeu, 26 jui 2008) By hywan Updated Validate/Ip.php Rev. 78 : Add the array support. At 2008-06-26 16:53:21 +0200 (Jeu, 26 jui 2008) By hywan Added Validate/Array.php Rev. 77 : Correct a bug. At 2008-06-26 16:53:06 +0200 (Jeu, 26 jui 2008) By hywan Updated Validate/Float.php Rev. 73 : Ameliorate the argument support. At 2008-06-23 18:58:37 +0200 (Lun, 23 jui 2008) By hywan Updated Validate/Abstract.php Rev. 72 : Change the constant, was incorrect. At 2008-06-23 18:57:20 +0200 (Lun, 23 jui 2008) By hywan Updated Validate/Empty.php Rev. 71 : Not usefull for now. At 2008-06-23 12:41:19 +0200 (Lun, 23 jui 2008) By hywan Deleted Validate/UriHttp.php Rev. 70 : Regex will be replace by the users's validators. At 2008-06-23 12:40:23 +0200 (Lun, 23 jui 2008) By hywan Deleted Validate/Regex.php Rev. 69 : Terminate the remake. At 2008-06-21 17:07:23 +0200 (Sam, 21 jui 2008) By hywan Updated Filter/Abstract.php Updated Filter/Array.php Updated Filter/Filter.php Updated Filter/Tag.php Rev. 64 : Correct a PHP bug. At 2008-06-19 16:58:03 +0200 (Jeu, 19 jui 2008) By hywan Updated Filter/Tag.php Rev. 63 : Edit the definition of operatione. At 2008-06-19 16:37:29 +0200 (Jeu, 19 jui 2008) By hywan Updated Filter/Integer.php Rev. 62 : Edit the definition of doubleEncode. At 2008-06-19 16:32:28 +0200 (Jeu, 19 jui 2008) By hywan Updated Filter/HtmlEntities.php Rev. 61 : Edit the definition of quoteStyle. At 2008-06-19 16:25:52 +0200 (Jeu, 19 jui 2008) By hywan Updated Filter/HtmlEntities.php Rev. 60 : Change the constant value (more logical now). At 2008-06-19 16:10:30 +0200 (Jeu, 19 jui 2008) By hywan Updated Filter/Integer.php Rev. 59 : Delete input. It's useless, Array make the same job. At 2008-06-19 15:56:34 +0200 (Jeu, 19 jui 2008) By hywan Deleted Filter/Input.php Rev. 58 : Remake all the package. At 2008-06-19 15:39:42 +0200 (Jeu, 19 jui 2008) By hywan Added Filter/Abstract.php Updated Filter/Alpha.php Updated Filter/AlphaNumeric.php Updated Filter/Array.php Updated Filter/Blank.php Updated Filter/Exception.php Updated Filter/Filter.php Updated Filter/HtmlEntities.php Updated Filter/Input.php Updated Filter/Integer.php Deleted Filter/Interface.php Updated Filter/Lower.php Updated Filter/Null.php Updated Filter/Space.php Updated Filter/Tag.php Updated Filter/Upper.php Rev. 57 : Correct some defaut with the inheritance of the abstract class. At 2008-06-19 12:22:46 +0200 (Jeu, 19 jui 2008) By hywan Updated Validate/Validate.php Rev. 56 : Remove the import of Hoa_Validate_Exception, useless. At 2008-06-19 10:59:35 +0200 (Jeu, 19 jui 2008) By hywan Updated Validate/Abstract.php Updated Validate/Alpha.php Updated Validate/AlphaNumeric.php Updated Validate/Email.php Updated Validate/Empty.php Updated Validate/Float.php Updated Validate/GreaterThan.php Updated Validate/Hexa.php Updated Validate/Integer.php Updated Validate/Ip.php Updated Validate/LessThan.php Updated Validate/Lower.php Updated Validate/Null.php Updated Validate/StringLength.php Updated Validate/Upper.php Rev. 55 : Finalize the package. At 2008-06-18 20:12:50 +0200 (Mer, 18 jui 2008) By hywan Updated Graph/AdjacencyList.php Updated Graph/Graph.php Rev. 51 : Edit the __toString method. Language DOT wasnot correct. At 2008-06-18 19:47:56 +0200 (Mer, 18 jui 2008) By hywan Updated Graph/AdjacencyList.php Rev. 50 : Forget brackets … At 2008-06-18 19:36:04 +0200 (Mer, 18 jui 2008) By hywan Updated Acl/Acl.php Rev. 49 : Add the DOT language support. At 2008-06-18 19:34:15 +0200 (Mer, 18 jui 2008) By hywan Updated Acl/Acl.php Rev. 47 : Edit because of the Hoa_Graph modifications. At 2008-06-18 19:04:41 +0200 (Mer, 18 jui 2008) By hywan Updated Acl/Group.php Rev. 46 : Finalize the package. At 2008-06-18 17:11:23 +0200 (Mer, 18 jui 2008) By hywan Updated Graph/AdjacencyList.php Updated Graph/Graph.php Updated Graph/Node/SimpleNode.php Rev. 45 : Change the package. At 2008-06-18 16:29:00 +0200 (Mer, 18 jui 2008) By hywan Deleted Graph/AdjacencyList/ Updated Graph/AdjacencyList.php Updated Graph/Graph.php Added Graph/Node/ Deleted Graph/Node/Interface.php Added Graph/Node/Interface.php Deleted Graph/Node/SimpleNode.php Added Graph/Node/SimpleNode.php Rev. 44 : Change the package. At 2008-06-18 16:26:14 +0200 (Mer, 18 jui 2008) By hywan Updated Graph/AdjacencyList/Interface.php Updated Graph/AdjacencyList/SimpleNode.php Rev. 43 : Add possibilities. At 2008-06-16 23:51:00 +0200 (Lun, 16 jui 2008) By hywan Updated Graph/AdjacencyList/SimpleNode.php Updated Graph/AdjacencyList.php Rev. 39 : Last reading. At 2008-06-12 19:27:05 +0200 (Jeu, 12 jui 2008) By hywan Updated Session/Flash.php Updated Session/Option.php Updated Session/Session.php Rev. 30 : Replace boolean per constants CONVERT_TO_OBJECT|ARRAY. At 2008-06-11 11:02:39 +0200 (Mer, 11 jui 2008) By hywan Updated Configuration/Array.php Updated Configuration/Configuration.php Updated Configuration/Ini.php Updated Configuration/Xml.php Updated Configuration/Yaml.php Rev. 29 : Change die to exit method. Die is depreciated. At 2008-06-11 10:46:52 +0200 (Mer, 11 jui 2008) By hywan Updated Exception.php Rev. 27 : Correct some option name. At 2008-06-10 23:47:59 +0200 (Mar, 10 jui 2008) By hywan Updated Session/Option.php Rev. 26 : Add the getValue for a select element. At 2008-06-10 16:04:48 +0200 (Mar, 10 jui 2008) By hywan Updated Form/Element/Select.php Updated Form/Element/SelectOptgroup.php Updated Form/Element/SelectOption.php Rev. 25 : Remove an empty line. At 2008-06-10 15:31:26 +0200 (Mar, 10 jui 2008) By hywan Updated Locale/Locale.php Rev. 24 : Correct a bug in the iterator. At 2008-06-10 15:14:57 +0200 (Mar, 10 jui 2008) By hywan Updated Form/Form.php Rev. 23 : Correct a bug in the iterator. At 2008-06-10 15:14:37 +0200 (Mar, 10 jui 2008) By hywan Updated Form/Form.php Rev. 22 : Correct a bug during the validation. At 2008-06-10 14:39:40 +0200 (Mar, 10 jui 2008) By hywan Updated Form/Element/Abstract.php Updated Form/Element/Select.php Updated Form/Form.php Rev. 21 : Damned ! The bug 20221 is here … At 2008-06-10 12:26:29 +0200 (Mar, 10 jui 2008) By hywan Updated Form/Decorator/Select.php Updated Form/Decorator/SelectOptgroup.php Rev. 20 : Change boundaries. At 2008-06-10 10:39:57 +0200 (Mar, 10 jui 2008) By hywan Updated Validate/StringLength.php Rev. 19 : Make the difference between integer and float. At 2008-06-10 10:35:32 +0200 (Mar, 10 jui 2008) By hywan Added Validate/Float.php Updated Validate/Integer.php Rev. 18 : Add the validator output support. At 2008-06-09 16:39:51 +0200 (Lun, 09 jui 2008) By hywan Updated Form/Decorator/InputCheckbox.php Updated Form/Decorator/InputFile.php Updated Form/Decorator/InputPassword.php Updated Form/Decorator/InputRadio.php Updated Form/Decorator/Select.php Rev. 17 : Remake the error management and write the most of the validator. At 2008-06-09 16:20:16 +0200 (Lun, 09 jui 2008) By hywan Updated Validate/Abstract.php Updated Validate/Alpha.php Updated Validate/AlphaNumeric.php Updated Validate/Email.php Updated Validate/Empty.php Updated Validate/GreaterThan.php Updated Validate/Hexa.php Updated Validate/Integer.php Updated Validate/Ip.php Updated Validate/LessThan.php Updated Validate/Lower.php Updated Validate/StringLength.php Updated Validate/Upper.php Updated Validate/Validate.php Rev. 16 : 2 bugs corrected : Mail does not exist, it is Hoa_Mail class, and add the set/get result method. At 2008-06-09 16:18:17 +0200 (Lun, 09 jui 2008) By hywan Updated Mail/Rfc882.php Rev. 15 : Add the get method and set up the iterator. At 2008-06-09 12:28:45 +0200 (Lun, 09 jui 2008) By hywan Updated Form/Form.php Rev. 14 : Remove useless code, correct getValue, and add getName methods. At 2008-06-09 12:17:04 +0200 (Lun, 09 jui 2008) By hywan Updated Form/Element/Abstract.php Updated Form/Element/InputReset.php Updated Form/Element/InputSubmit.php Rev. 13 : Forget to add the namespace expiration exception. At 2008-06-09 11:09:55 +0200 (Lun, 09 jui 2008) By hywan Added Session/Exception/Namespace_Is_Expired.php Rev. 11 : Reset some option (bad default value). At 2008-06-08 18:51:30 +0200 (Dim, 08 jui 2008) By hywan Updated Session/Option.php Rev. 8 : Add fonctionnalities and tests. At 2008-06-08 12:25:52 +0200 (Dim, 08 jui 2008) By hywan Updated Session/Namespace.php Updated Session/Session.php Rev. 6 : Add the new exception support. At 2008-06-07 23:24:49 +0200 (Sam, 07 jui 2008) By hywan Added Session/Exception/ Added Session/Exception/Session_Is_Expired.php Updated Session/Session.php Project tree (at the youngest revision) ************************** Framework/ I18n/ i18n.php utf8.php phputf8/ strspn.php strcspn.php str_pad.php LICENSE mbstring/ core.php native/ core.php strcasecmp.php README stristr.php utils/ validation.php patterns.php specials.php position.php bad.php unicode.php ascii.php trim.php str_ireplace.php substr_replace.php ucfirst.php str_split.php ord.php strrev.php ucwords.php File/ Util.php Dir.php Exception.php File.php Upload.php Exception/ Upload_Extension.php StdClass/ Util.php Exception.php StdClass.php Archive/ Pkg/ Exception.php Pkg.php todo.txt Mail/ Protocol/ Exception.php Abstract.php Smtp.php Antispam.php Rfc882.php Exception.php Mail.php Transport/ Sendmail.php Exception.php Abstract.php Smtp.php Mime.php Framework.php Controller/ Router/ Pattern.php Get.php Interface.php Standard.php Rewrite.php Exception.php Dispatcher/ Action.php Abstract.php Request/ Abstract.php Action/ Standard.php Exception/ Controller_Is_Not_Found.php Controller_Not_Extends_Action_Standard.php Controller_Reflection.php Response_Pointer_Already_Exists.php Action_Is_Not_Found.php Router_Does_Not_Return_An_Array.php Plugin_Is_Already_Registered.php Router_Factory.php Front.php Plugin/ Interface.php Standard.php Response/ Standard.php Session/ Namespace.php Flash.php Exception.php Session.php SaveHandler/ Interface.php Exception/ Session_Is_Expired.php Namespace_Is_Expired.php Option.php Exception.php Filter/ HtmlEntities.php Null.php Space.php Tag.php Upper.php Integer.php Array.php Exception.php Abstract.php Alpha.php Filter.php Blank.php AlphaNumeric.php Lower.php Version/ Version.php Mime/ Exception.php Parameter.php mime.types.ini Mime.php Socket/ Exception.php Socket.php Validate/ Validate.php Upper.php … (je mets pas tout, ça ne sert à rien …)
On notera l'originalité de mes messages pour chaque commit

Je pense que ça peut servir. Faites vous plaisir en mettant les variables $repos, $in, et $cl en paramètre de l'appel ($1, $2 et $3) par exemple. Je ne l'ai pas fait ici pour raison de clarté.

Ah oui, et bien sûr, l'exécution du fichier :

Code : Tout sélectionner

$ chmod u+x Changelog.sh $ ./Changelog.sh Changelog built at : /Users/hywan/Sites/Hoa/Project/Framework/Trunk/CHANGELOG
Voilà :). Je me suis pas amusé à gérer toutes les erreurs hein, c'est un script perso tout bête mais utile.
« Un handicap est le résultat d'une rencontre entre une déficience ou différence et une incapacité de la société à répondre à celle-ci. »

Hoa : http://hoa-project.net (sur @hoaproject).

Administrateur PHPfrance
Administrateur PHPfrance | 3131 Messages

29 juin 2008, 10:23

Bah... Qu'est-ce qui ne te plaisait pas dans le "svn log -v" d'origine ? :P

ViPHP
ViPHP | 4674 Messages

29 juin 2008, 11:58

Qu'il ne te donne qu'une révision (la première soit dit en passant).
Là je produit un changelog pour le dossier courant et tous ses sous-dossiers par ordre de révisions, avec une belle mise en page. C'est plus pratique à lire pour tout le monde au lieu d'écrire svn log -v -r 1 … … … je viens me rendre compte qu'on peut faire svn log -v -r 1:HEAD … … les boules #-o. Pourquoi j'y ai pas pensé … Heureusement que j'ai passé seulement 10mn à pondre le script …

Bah même, le mien est plus jolie, et toc |(X. Uè voilà, on va dire ça :lol:. Les A, D, U, etc., deviennent Added, Deleted, Updated, etc., et la mise en forme est plus sympa …

Mais sinon, c'est un bon moyen pour que les gens fassent connaissance avec svnlook aussi, hein, non ?
Ah, j'ai trouvé un avantage :lol:, on peut faire une sortie XML plus facilement avec mon script, voilà, toc. Même pas en fait, svn log -v -r 1:HEAD --xml revient au même … Bon ok, ça sert à rien :mrgreen:.
« Un handicap est le résultat d'une rencontre entre une déficience ou différence et une incapacité de la société à répondre à celle-ci. »

Hoa : http://hoa-project.net (sur @hoaproject).