added a new configuration item commit_notification_url

This commit is contained in:
hyung-hwan 2015-08-13 05:33:23 +00:00
parent 81367f8ade
commit 38e63af4fb
3 changed files with 32 additions and 3 deletions

View File

@ -257,6 +257,13 @@ code_folder_readme = "README.wiki,README.txt,README"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
email_sender = "" email_sender = ""
;------------------------------------------------------------------------------
; URL to include when sending a commit notification message.
; You can specify multiple urls. in fact, it's a free text.
; Replacement is performed for ${REV}, ${AUTHOR}, ${PROJECTID}.
;------------------------------------------------------------------------------
commit_notification_url = ""
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Codepot sets this revision property to assign a tag to a specific revision. ; Codepot sets this revision property to assign a tag to a specific revision.
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

View File

@ -54,7 +54,8 @@ sub get_config
database_driver => $cfg->param ("database_driver"), database_driver => $cfg->param ("database_driver"),
database_prefix => $cfg->param ("database_prefix"), database_prefix => $cfg->param ("database_prefix"),
email_sender => $cfg->param ("email_sender") email_sender => $cfg->param ("email_sender"),
commit_notification_url => $cfg->param ("commit_notification_url")
}; };
return $config; return $config;
@ -343,6 +344,17 @@ sub email_message_to_project_members
return (1, undef); return (1, undef);
} }
sub format_commit_url
{
my ($fmt, $projectid, $author, $rev) = @_;
my $out = $fmt;
$out =~ s/\$\{PROJECTID\}/$projectid/g;
$out =~ s/\$\{AUTHOR\}/$author/g;
$out =~ s/\$\{REV\}/$rev/g;
return $out;
}
#------------------------------------------------------------ #------------------------------------------------------------
# MAIN # MAIN
#------------------------------------------------------------ #------------------------------------------------------------
@ -371,8 +383,17 @@ if (!defined($dbh))
write_commit_log ($dbh, $cfg->{database_prefix}, $REPOBASE, $REV, $AUTHOR); write_commit_log ($dbh, $cfg->{database_prefix}, $REPOBASE, $REV, $AUTHOR);
my $commit_subject = "Commit $REV by $AUTHOR in $REPOBASE"; my $commit_subject = "Commit r$REV by $AUTHOR in $REPOBASE";
my $commit_message = $commit_subject; # TODO: compose a proper URL my $commit_message = '';
if ($cfg->{commit_notification_url} eq '')
{
$commit_message = $commit_subject;
}
else
{
$commit_message = 'See ' . format_commit_url($cfg->{commit_notification_url}, $REPOBASE, $AUTHOR, $REV);
}
email_message_to_project_members ($cfg, $dbh, $cfg->{database_prefix}, $REPOBASE, $commit_subject, $commit_message); email_message_to_project_members ($cfg, $dbh, $cfg->{database_prefix}, $REPOBASE, $commit_subject, $commit_message);

View File

@ -85,6 +85,7 @@ function load_ini ($file)
array ('cloc_command_path', 'string', CODEPOT_CFG_DIR.'/cloc.pl'), array ('cloc_command_path', 'string', CODEPOT_CFG_DIR.'/cloc.pl'),
array ('code_folder_readme', 'string', 'README'), array ('code_folder_readme', 'string', 'README'),
array ('email_sender', 'string', ''), array ('email_sender', 'string', ''),
array ('commit_notification_url', 'string', ''),
array ('svn_tag_property', 'string', 'codepot:tag'), array ('svn_tag_property', 'string', 'codepot:tag'),