From 38e63af4fb0f53f57ccd55445731841741755c6e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 13 Aug 2015 05:33:23 +0000 Subject: [PATCH] added a new configuration item commit_notification_url --- codepot/etc/codepot.ini.in | 7 +++++++ codepot/etc/post-commit.in | 27 ++++++++++++++++++++++++--- codepot/src/config.php.in | 1 + 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index 09f4b845..fd9a0871 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -257,6 +257,13 @@ code_folder_readme = "README.wiki,README.txt,README" ;------------------------------------------------------------------------------ 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. ;------------------------------------------------------------------------------ diff --git a/codepot/etc/post-commit.in b/codepot/etc/post-commit.in index d7257b41..a2256150 100644 --- a/codepot/etc/post-commit.in +++ b/codepot/etc/post-commit.in @@ -54,7 +54,8 @@ sub get_config database_driver => $cfg->param ("database_driver"), 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; @@ -343,6 +344,17 @@ sub email_message_to_project_members 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 #------------------------------------------------------------ @@ -371,8 +383,17 @@ if (!defined($dbh)) write_commit_log ($dbh, $cfg->{database_prefix}, $REPOBASE, $REV, $AUTHOR); -my $commit_subject = "Commit $REV by $AUTHOR in $REPOBASE"; -my $commit_message = $commit_subject; # TODO: compose a proper URL +my $commit_subject = "Commit r$REV by $AUTHOR in $REPOBASE"; +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); diff --git a/codepot/src/config.php.in b/codepot/src/config.php.in index af4d2c88..76f965cd 100644 --- a/codepot/src/config.php.in +++ b/codepot/src/config.php.in @@ -85,6 +85,7 @@ function load_ini ($file) array ('cloc_command_path', 'string', CODEPOT_CFG_DIR.'/cloc.pl'), array ('code_folder_readme', 'string', 'README'), array ('email_sender', 'string', ''), + array ('commit_notification_url', 'string', ''), array ('svn_tag_property', 'string', 'codepot:tag'),