Integrated SVN source management and Mantis bug tracking

Source: Internet
Author: User

Integrated SVN source management and Mantis bug tracking (Windows)

To integrate mantis and SVN, you need several tools:
SVN client, TortoiseSVN,: http://tortoisesvn.net/
SVN server, this should all have.
Mantis Defect Tracking System http://www.mantisbt.org/


First set the properties of the project in the TortoiseSVN, right-click on the directory, properties, in the Subversion column, add these several attributes

Bugtraq:label =issue
Bugtraq:url = http:///mantis/view.php?id=%BUGID%
Bugtraq:message = Issue%bugid%
Bugtraq:warnifnoissue = True

To the corresponding SVN repository, locate the hooks directory, create a Post-commit.bat file, and copy the following into:

REM Post-commithook for MANTISBT integration

Path to the REM REPOSSVN repository
REM REV Version Information
REM Details_file is the repository directory where a log directory is created in the Repository directory to store logs
REM Set Phprc=d:\easyphp\apache default will be read under Easyphp\apach directory using php.ini modified under Windows directory

REM copied checkin.php for modification, renamed to checkin_svn.php if there is a Chinese transmission, need to modify checkin_svn.php
REM increases the catch-change function $t _comment = mb_convert_encoding ($t _comment, "Utf-8", "GB2312");
REM modification position in "foreach ($t _issues as $t _issue_id) {" Front
REM mb_convert_encoding This function requires extended file Php_mbstring.dll Support ~ ~
REM $t _comment =iconv ("UTF-8", "Gb2312//translit", $t _comment); It is said that this code conversion efficiency is higher

SET repos=%1
SET rev=%2
SET details_file=d:\svn\no1\log\svnfile_%rev%
SET Log_file=d:\svn\no1\log\svnfile_%rev%_log
Set Apr_iconv_path=d:\easyphp\subversion\iconv
Set Phprc=d:\easyphp\apache
Set path=%path%;D: \easyphp\php5;d:\easyphp\subversion\bin;


echo ****** Source code change ******>>? Tails_file%

echo SVN modifier: >>? Tails_file%
Svnlook author-r%rev%%repos%>>? Tails_file%

echo SVN Modified date: >>? Tails_file%
Svnlook date-r%rev%%repos%>>? Tails_file%

Echo SVN version: >>? Tails_file%
Echo%rev%>>? Tails_file%

Echo SVN commit comment: >>? Tails_file%
Svnlook log-r%rev%%repos%>>? Tails_file%

echo SVN modified detail: >>? Tails_file%
Svnlook diff-r%rev%%repos%>>? Tails_file%


REM php.exe. \checkin_svn.php Information File log file
Php.exe d:\easyphp\www\mantis\core\checkin_svn.php<? Tails_file%>%log_file%

Del? Tails_file%
Del%log_file%


Finally, modify the config_inc.php in the Mantis installation directory to include the following (SVN users in the mantis system):

$g _source_control_notes_view_status =vs_public;
$g _source_control_account = ' SVN ';
$g _source_control_set_status_to = OFF;
$g _source_control_regexp = "/\bissue[#]{0,1} (\d+) \b/i";

After completing these steps, you can publish the content to the corresponding bug tracking system while SVN submits the new version.

For example, to modify a source file, SVN commit, in the upper right of the issue column to enter the specific Issue/bug number to be submitted to,
Then enter a specific description in the message box below, and the SVN hook will automatically write to the corresponding entry in the mantis that you entered when you submitted it.

There are still some problems in the use process after completing the above work
1, the defect number is not mandatory input, if you do not enter the defect number, can still submit
2, entered the wrong defect number, the system is still submitted, but there is no relevant content in the defective system
To solve this problem, we need to verify the defect information before submitting it.
First, create Pre-commit.bat check defect number

REM Pre-commit.bathook for MANTISBT integration
Set repos=%1
Set txn=%2
SET Details_file=d:\svn\no1\log\svnfile
SET Log_file=d:\svn\no1\log\svnfile_log
Set Apr_iconv_path=d:\easyphp\subversion\iconv
Set Phprc=d:\easyphp\apache
Set path=%path%;D: \easyphp\php5;d:\easyphp\subversion\bin;

REM writes annotation information to Details_file
Svnlook Log "%repos%"-T "%txn%" >>? Tails_file%

REM performs checkin_svn_pre_commit.php to verify that the defect number is present in the defect system and returns the output information to log_file if it does not exist
Php.exe d:\easyphp\www\mantis\core\checkin_svn_pre_commit.php<? Tails_file%>%log_file%

REM Check whether there is content in Log_file, if there is content, go to error prompt
for/f "tokens=1,2* delims="%%i in (%log_file%) do goto err

Del? Tails_file%
Del%log_file%
Exit 0

: Err
echo Defect list does not exist, please fill in the correct number of defects, submit the termination! 1>&2
Del? Tails_file%
Del%log_file%
Exit 1

Ii. creating checkin_svn_pre_commit.php to database Lieutenant-Colonel Flaw information
Copy checkin.php content New checkin_svn_pre_commit.php file
Delete # add note to each bug is only once after the exit (0); content, modified to the following:

# add note to Eachbug only once
  $t _issues = Array_unique ($t _ issues);
  $t _fixed_issues = Array_unique ($t _fixed_issues);
        $t _issues_svn = Array_unique ($t _issues);
  
# encoding conversion.
  $t _comment = mb_convert_encoding ($t _comment, "Utf-8", "GB2312");  
  
  # Judging the database Is there
  foreach ($t _issues_svn as $t _issue_id) {
    
    $query = "SELECT *
    frommantis_bug_table
    wherebug_text_id= ' $t _issue_id '";
  $result = Db_query ($query);
  $issues _raw_count = db_num_rows ($result);
   
  if ($issues _raw_count  ==0) {
   echo "$t _issue_id";
  
  }
  
 exit (0);


At this point most of the work has been done, but there are still some problems
1 when new and other operations, sometimes submitted no revenue issue prompt box, but at this time still need to enter the defect number
The test can be requested, in the submission of comments, according to issue 1 manual written defect number, you can submit

Integrated SVN source management and Mantis bug tracking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.