mantis整合svn续:把提交的所有信息自动保存为note
2013-06-05 16:30
375 查看
/article/1606224.html
在前面两篇转载的文章中,介绍了mantis和svn的整合
/article/1606228.html
/article/1606227.html
但有这样一个需求:在提交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()
[php]
view plaincopyprint?
# 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 ) );
}
把修改放在note上
[php]
view plaincopyprint?
# 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 );
}
在前面两篇转载的文章中,介绍了mantis和svn的整合
/article/1606228.html
/article/1606227.html
但有这样一个需求:在提交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()
[php]
view plaincopyprint?
# 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 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 ) ); }
把修改放在note上
[php]
view plaincopyprint?
# 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 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 ); }
相关文章推荐
- mantis整合svn续:把提交的所有信息自动保存为note
- java 中 SVN 设置所有文件及子目录 needs-lock, svn 提交时自动设置 needs-lock, 及版本不一致问题
- 当 App 崩溃的时,把崩溃信息保存到本地的同时,自动给 GitHub 提交崩溃 issue。
- Eclipse使用SVN,停用自动保存密码功能。删除eclipse自动保存的SVN信息
- 如何删除myeclipse下自动保存的svn账号信息
- vue + store2实现未提交信息自动保存
- 提交订单系统自动发送邮件到收件人邮箱优化(邮件内容信息以月为单位)
- SVN客户端(TortoiseSVN)保存密码自动登录后,如何切换使用其它帐户登录方法
- svn 提交代码 自动过滤技巧
- C#网页自动登录和提交POST信息的多种方法
- SVN在另类环境中实现自动提交的方法
- svn版本信息自动更新到源代码
- windows环境下svn本地提交后自动更新提交到服务器的项目根目录
- CentOS7安装Git与RedMine及整合(提交代码自动更新RedMine状态)
- svn 设置必须填写说明注释 和 提交后自动更新到服务器目录
- PhireeNote- 只有自动保存功能的简易记事本
- spring cloud-Swagger2整合Eureka,实现Eureka页面自动跳转到Swagger2UI界面查看服务接口信息
- C#实现的三种模拟自动登录和提交POST信息的方法
- C#网页自动登录和提交POST信息的多种方法
- 提交订单系统自动发送邮件到收件人邮箱优化(邮件内容信息以月为单位)