读书人

mantis调整svn续:把提交的所有信息自

发布时间: 2012-08-27 21:21:57 作者: rapoo

mantis整合svn续:把提交的所有信息自动保存为note

在前两篇文章中,已经完成了mantis和svn的整合

http://blog.csdn.net/newjueqi/article/details/7785373

http://blog.csdn.net/newjueqi/article/details/7785382


但有这样一个需求:在提交svn后,mantis能把提交的所有信息自动保存为note(用"bug #0001" 和 “fixed bug #0001” 两种格式的记录都能提交note)

在mantis的源码中没法实现,于是研究了一下mantis的源码,最终实现了这个功能:


我把代码放在github上 https://github.com/newjueqi/source-integration


效果如图所示:

mantis调整svn续:把提交的所有信息自动保存为note


具体的实现 https://github.com/newjueqi/source-integration/blob/master/Source/Source.API.php Source_Process_Changesets()


# Start add note for  issuesforeach( $t_note_bugs as $t_bug_id => $t_changeset ) {# make sure the bug exists before processingif ( !bug_exists( $t_bug_id ) ) {continue;}# fake the history entries as the committer/author user ID$t_user_id = null;if ( $t_changeset->committer_id > 0 ) {$t_user_id = $t_changeset->committer_id;} else if ( $t_changeset->user_id > 0 ) {$t_user_id = $t_changeset->user_id;}if ( !is_null( $t_user_id ) ) {$g_cache_current_user_id = $t_user_id;} else if ( !is_null( $t_current_user_id ) ) {$g_cache_current_user_id = $t_current_user_id;} else {$g_cache_current_user_id = 0;}# generate the branch mappings$t_version = '';$t_pvm_version_id = 0;if ( $t_enable_mapping ) {$t_repo_id = $t_changeset->repo_id;if ( !isset( $t_mappings[ $t_repo_id ] ) ) {$t_mappings[ $t_repo_id ] = SourceMapping::load_by_repo( $t_repo_id );}if ( isset( $t_mappings[ $t_repo_id ][ $t_changeset->branch ] ) ) {$t_mapping = $t_mappings[ $t_repo_id ][ $t_changeset->branch ];if ( Source_PVM() ) {$t_pvm_version_id = $t_mapping->apply_pvm( $t_bug_id );} else {$t_version = $t_mapping->apply( $t_bug_id );}}}# generate a note messageif ( $t_enable_message ) {             $changelog = "";             foreach($t_changeset->files as $file) {                 switch($file->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.="    ".$file->filename.'<br/>';             } $t_message = sprintf( $t_message_template, $t_changeset->branch, $t_changeset->revision, $t_changeset->timestamp, $t_changeset->message, $t_repos[ $t_changeset->repo_id ]->name, $t_changeset->id, $t_changeset->author, $changelog );} else {$t_message = '';}$t_bug = bug_get( $t_bug_id );bugnote_add( $t_bug_id, $t_message );}





读书人网 >CVS SVN

热点推荐