Mantis SVN Integration:Adding extra info to the Note


http://blog.crazytje.be/mantis-svn-integration-adding-extra-info-to-the-note/
In my previous post I talked about Mantis and SVN integration.
One thing I was missing that I used to have is more control over the message(note)that gets posted.
The source control plug-in supports the follwing argments:
$1 for branch $2 for revision $3 for timestamp $4 for comit message $5 for repository name $6 for changeset ID An example what message you can make:
Revision: $2 in repository: $5<br /> On: $3 <br />Message:<br /> $4
Resoults in:
Revision: 484 in repository MyRepo
On: 2011-08-14 18:15

Message:
fixed issue 243: war was fixed, we have world peace!
This wasn’t what I wanted、the output I had in the previous mants version was like this:
Revision: 484
Commit by: Crazy

Message:
fixed issue 243: war was fixed, we have world peace!

Changes:
M    /trunk/war_ annihiliator.php
 
Two parameters are missing to get this reult、those are:
$7 for author $8 for the changes.After diving in the source,it was fairly easury to add this functionlity
All the data was already there.I asume it wasn’t added because when working with git it doesn’t have this info.
Here is the patch that you need to applyto get the 2 extra parameters:
diff -crB ./Source/Source.API.php ./Source/Source.API.php
*** ./Source/Source.API.php    2011-08-03 14:50:07.000000000 -0500
--- ./Source/Source.API.php    2011-08-14 14:48:04.000000000 -0500
***************
*** 288,295 ****
$t_resolution = config_get( 'plugin_Source_bugfix_resolution' );
$t_handler = config_get( 'plugin_Source_bugfix_handler' );
$t_message_template = str_replace(
!         array( '$1', '$2', '$3', '$4', '$5', '$6' ),
!         array( '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s' ),
config_get( 'plugin_Source_bugfix_message' ) );
 
$t_mappings = array();
--- 288,295 ----
$t_resolution = config_get( 'plugin_Source_bugfix_resolution' );
$t_handler = config_get( 'plugin_Source_bugfix_handler' );
$t_message_template = str_replace(
!         array( '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8' ),
!         array( '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s', '%7$s', '%8$s'),
config_get( 'plugin_Source_bugfix_message' ) );
 
$t_mappings = array();
***************
*** 340,346 ****
 
# generate a note message
if ( $t_enable_message ) {
!             $t_message = sprintf( $t_message_template, $t_changeset-&gt;branch, $t_changeset-&gt;revision, $t_changeset-&gt;timestamp, $t_changeset-&gt;message, $t_repos[ t_changeset-&gt;repo_id ]-&gt;name, $t_changeset-&gt;id );
} else {
$t_message = '';
}
--- 340,357 ----
 
# generate a note message
if ( $t_enable_message ) {
! $changelog = "";
! foreach($t_changeset-&gt;files as $file) {
! switch($file-&gt;action) {
! case 'add': $changelog.='A'; break;
! case 'rm' : $changelog.='D'; break;
! case 'mod': $changelog.='M'; break;
! case 'mv' : $changelog.='R'; break;
! default : $changelog.='C'; break;
! }
! $changelog.="&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;".$file-&gt;filename.'&lt;br/&gt;';
! }
!             $t_message = sprintf( $t_message_template, $t_changeset-&gt;branch, $t_changeset-&gt;revision, $t_changeset-&gt;timestamp, $t_changeset-&gt;message, $t_repos[ t_changeset-&gt;repo_id ]-&gt;name, $t_changeset-&gt;id, $t_changeset-&gt;author, $changelog );
} else {
$t_message = '';
}
In the patch above I left the changes in the langage files.Here is a compute version that has the langage file udates as:Mantis Source Control Patch
To apply the patch,run the following command:
cd /mymantispath/plugins/
echo "Do a dry run first to see if it works"
patch --dry-run -p1 -i mantis.patch
echo "Now apply it for real"
patch -p1 -i mantis.patch
 
After applying the patch in the zip the text will have changed on the configration page for'source control'
It will now include the$7(author)and 8(modifications)parameters.
 
The message template I'm using is:
Revision: $2 <br /> Commit by: $7 <br /> <br /> Message:<br /> $4<br /> <br /> Changes:<br /> $8<br />
This gives the follwing output:
Revision: 484
Commit by: Crazy

Message:
fixed issue 243: war was fixed, we have world peace!

Changes:
M    /trunk/war_ annihiliator.php
 
Be aware that this hasn’t been tested with Github.Most people only use 1 source control system、but those that mix、test this first!