Integrate SVN source code management and mantis defect tracking

Source: Internet
Author: User
Tags svn client tortoisesvn

ArticleSource Address:Http://www.cppblog.com/cloud/archive/2008/09/11/61606.aspx

To integrate mantis and Svn, several tools are required:
SVN client, tortoisesvn,: http://tortoisesvn.net/
SVN server, this should all be available.
Mantis defect tracking system http://www.mantisbt.org/

First, set the project attributes in tortoisesvn, right-click the directory, and add these attributes to the Subversion column.

Bugtraq: Label = issue
Bugtraq: url = http: // % 3 cmantisserver % 3E/mantis/view. php? Id = % bugid %
Bugtraq: Message = issue % bugid %
Bugtraq: warnifnoissue = true

To the corresponding SVN repository, find the hooks directory, create a post-commit.bat file, and load the following content:

Rem post-commit hook for mantisbt Integration

Path of the REM repos SVN Repository
Rem rev version information
Rem details_file is the version library directory. A log directory is created under the version library directory to store logs.
Rem set phprc = D: \ easyphp \ apache is modified by default using PHP. ini in the Windows directory, and then read the files in the easyphp \ Apach directory.

Rem copied checkin. php and renamed it checkin_svn.php. If there is a Chinese transmission, you need to modify checkin_svn.php.
Added the capture function $ t_comment = mb_convert_encoding ($ t_comment, "UTF-8", "gb2312 ");
The position of the REM modification is in front of "foreach ($ t_issues as $ t_issue_id) {".
Rem mb_convert_encoding this function requires extension file php_mbstring.dll support ~~
Rem $ t_comment = iconv ("UTF-8", "gb2312 // Transcoder", $ t_comment); it is said that this encoding is more efficient

 

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 ******> % details_file %

Echo SVN modifier: >>% details_file %
Svnlook author-R % rev % repos %> % details_file %

Echo SVN modification date: >>% details_file %
Svnlook date-R % rev % repos %> % details_file %

Echo SVN version: >>% details_file %
Echo % rev %> % details_file %

Echo SVN submit comments: >>% details_file %
Svnlook log-R % rev % repos %> % details_file %

Echo SVN modification details: >>% details_file %
Svnlook diff-R % rev % repos %> % details_file %

Rem php.exe. \ checkin_svn.php information file Log File
Php.exe D: \ easyphp \ www \ mantis \ core \ checkin_svn.php <% details_file %> % LOG_FILE %

Del % details_file %
Del % LOG_FILE %

Finally, modify config_inc.php In the Mantis installation directory and add the following content (SVN users must be included 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 release the content to the corresponding defect tracking system when submitting a new version of SVN.

For example, when you modify a source file SVN commit, enter the specific issue/bug number to be submitted in the issue column on the upper right,
Then, enter the specific description in the following message box, And the svn hook will automatically write the entered content to the corresponding entry in Mantis.

Some problems still exist in the use process after completing the above work.
1. The defect number is not entered forcibly. If the defect number is not entered, it can still be submitted.
2. If an incorrect defect number is entered, the system still submits the error code, but there is no relevant content in the defect system.
To solve this problem, you must verify the defect information before submitting it.
1. Create a pre-commit.bat validation defect number

Rem pre-commit.bat hook 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 the annotation information to details_file
Svnlook log "% repos %"-T "% txn %"> % details_file %

Rem executes checkin_svn_pre_commit.php to check whether the defect ticket number exists in the defect system. If not, the output information is returned to LOG_FILE.
Php.exe D: \ easyphp \ www \ mantis \ core \ checkin_svn_pre_commit.php <% details_file %> % LOG_FILE %

Rem checks whether there is any content in LOG_FILE. If there is any content, an error message is returned when it is transferred.
For/F "tokens = 1, 2 * delims =" % I in (% LOG_FILE %) Do goto err

Del % details_file %
Del % LOG_FILE %
Exit 0

: Err
The echo defect ticket does not exist. Please enter the defect ticket number correctly and submit it for termination! 1> & 2
Del % details_file %
Del % LOG_FILE %
Exit 1

2. Create checkin_svn_pre_commit.php to check the defect ticket information in the database.
Copy the checkin. php content and create the checkin_svn_pre_commit.php file.
Delete # add note to each bug after only once to exit (0); content, changed to the following content

# add note to each bug 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 ");
# Check whether the defect ticket number in the database exists
foreach ($ t_issues_svn as $ t_issue_id) {
$ query = "select *
from mantis_bug_table
where bug_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";
}< BR >}< br>
exit (0);

Now most of the work has been completed, but there are still some problems
1. When adding a new operation, sometimes the submission does not show an income issue prompt box, but you still need to enter the defect number.
The test may require that you manually write the defect ticket number in the form of Issue 1 when submitting comments to submit

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.