mantis整合svn续:把提交的所有信息自动保存为note
来源:互联网 发布:linux jdk 中没有jre 编辑:程序博客网 时间:2024/06/07 03:02
http://blog.csdn.net/newjueqi/article/details/7828432
在前面两篇转载的文章中,介绍了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
效果如图所示:
具体的实现 https://github.com/newjueqi/source-integration/blob/master/Source/Source.API.php Source_Process_Changesets()
- # Parse note bug links
- $t_note_bugs = array();
- # Find and associate resolve links with the changeset
- foreach( $p_changesets as $t_changeset ) {
- $t_bugs = Source_Parse_Buglinks( $t_changeset->message );
- foreach( $t_bugs as $t_bug_id ) {
- $t_note_bugs[ $t_bug_id ] = $t_changeset;
- }
- # Add the link to the normal set of buglinks
- $t_changeset->bugs = array_unique( array_merge( $t_changeset->bugs, $t_bugs ) );
- }
# Parse note bug links$t_note_bugs = array();# Find and associate resolve links with the changesetforeach( $p_changesets as $t_changeset ) {$t_bugs = Source_Parse_Buglinks( $t_changeset->message );foreach( $t_bugs as $t_bug_id ) {$t_note_bugs[ $t_bug_id ] = $t_changeset;}# Add the link to the normal set of buglinks$t_changeset->bugs = array_unique( array_merge( $t_changeset->bugs, $t_bugs ) );}
把修改放在note上
- # Start add note for issues
- foreach( $t_note_bugs as $t_bug_id => $t_changeset ) {
- # make sure the bug exists before processing
- if ( !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 message
- if ( $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 );
- }
# 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 );}
- mantis整合svn续:把提交的所有信息自动保存为note
- mantis整合svn续:把提交的所有信息自动保存为note
- 整合mantis和svn
- 当 App 崩溃的时,把崩溃信息保存到本地的同时,自动给 GitHub 提交崩溃 issue。
- 以把你所有的密码信息保存起来
- Eclipse使用SVN,停用自动保存密码功能。删除eclipse自动保存的SVN信息
- 如何删除myeclipse下自动保存的svn账号信息
- IOTest把登录信息保存,下次打开自动读取保存的登录信息,无需再次输入
- 把页面信息保存为csv文件
- Mantis SVN Integration : Adding extra info to the Note
- svn同mantis的整合实战(网上资料凌乱,自己做攻略)
- iOS CoreData 键值属性为NSString时可能会保存不了所有的信息的解决办法
- 凡是涉及要用文件保存信息的都把文件保存单独设置为一个类——FilePres
- 清除SVN保存的认证信息
- 清除MyEclipse保存的svn账户信息
- qt把画图的保存为文件
- android crash的log信息自动保存
- mantis+testlink bug系统的整合配置
- Linux常用命令小结
- 更换64位ubuntu12.04后一些软件的配置问题
- 图片上传预览 兼容 IE 6 7 8 9 FF chrome opera等版本
- Ubuntu配置Android模拟器
- 国家对五险一金的交纳说明
- mantis整合svn续:把提交的所有信息自动保存为note
- HDU-2094产生冠军
- 求序列的全排列
- error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js
- linux 使用sed 消除文本中的注释行
- hdu1195 Open the Lock
- 获取ios 应用程序信息
- Download and Install AndroidSDK in Ubuntu 12.04 (Precise Pangolin)
- 算法竞赛入门经典 8.3.1 棋盘覆盖问题