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 following arguments:

  • $1 for branch
  • $2 for revision
  • $3 for timestamp
  • $4 for commit 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

Results 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 mantis 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 result, those are:

  • $7 for author
  • $8 for the changes.

After diving in the source, it was fairly easy to add this functionality

All the data was already there. I assume it wasn’t added because when working with git it doesn’t have this info.

Here is the patch that you need to apply to 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 out the changes in the language files. Here is a complete version that has the language file updates as well:
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 configuration 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 following 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!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值