Modified:
trunk/doc/svn_hooks/hooks/post-commit
trunk/doc/svn_hooks/hooks/post-commit.tmpl
trunk/doc/svn_hooks/hooks/pre-commit
trunk/doc/svn_hooks/hooks/pre-commit.bat
trunk/doc/svn_hooks/hooks/pre-commit.tmpl
trunk/doc/svn_hooks/hooks/scripts/check-case-insensitive.pl
trunk/doc/svn_hooks/hooks/scripts/check-mime-type.pl
trunk/doc/svn_hooks/hooks/scripts/check-mime-type.py
trunk/doc/svn_hooks/hooks/scripts/commit-email.pl
trunk/doc/svn_hooks/hooks/scripts/commit-email.pl.in
trunk/doc/svn_hooks/hooks/scripts/commit_log_check.py
trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl
trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl.in
trunk/doc/svn_hooks/hooks/start-commit
trunk/doc/svn_hooks/hooks/start-commit.tmpl
Log:
添加 subversion 与 mantis 互动;
commit-email.pl: 限制邮件长度,只发送 differ 前 1000 行;
已修改: trunk/doc/svn_hooks/hooks/post-commit
===================================================================
--- trunk/doc/svn_hooks/hooks/post-commit 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/post-commit 2006-07-05 11:37:38 UTC (rev 27)
@@ -52,3 +52,20 @@
$TOOLS_DIR/commit-email.pl "$REPOS" "$REV" -m "." --from from@mydomain -r noreply@mydomain -s "[Test]" list@mydomain
#$TOOLS_DIR/log-commit.py --repository "$REPOS" --revision "$REV"
+
+############################################################
+#
+# Mantisbt integration ( http://www.worldhello.net )
+#
+############################################################
+SVNLOOK=/usr/bin/svnlook
+SED=/bin/sed
+MANTISBT=/wwwroot/bugs/bugs
+PHP=/usr/bin/php
+
+if [ -f "$MANTISBT/core/checkin.php" ]; then
+ export LC_ALL=zh_CN.utf8
+ commitlog=`$SVNLOOK log -r "$REV" "$REPOS" | $SED -e 's/\$/\\\\n/g'`
+ commitdiff=`$SVNLOOK diff -r "$REV" "$REPOS" | head -25 | $SED -e 's/\$/\\\\n/g'`
+ echo -e "$commitlog\n\n****** Source code change ******\nRepository: $REPOS, Revision: $REV.\n\n$commitdiff" | $PHP -q $MANTISBT/core/checkin.php
+fi
\ No newline at end of file
已修改: trunk/doc/svn_hooks/hooks/post-commit.tmpl
===================================================================
--- trunk/doc/svn_hooks/hooks/post-commit.tmpl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/post-commit.tmpl 2006-07-05 11:37:38 UTC (rev 27)
@@ -52,3 +52,20 @@
$TOOLS_DIR/commit-email.pl "$REPOS" "$REV" -m "." -r no-r...@example.org -s "[Project-svn]" commit-...@example.org
#$TOOLS_DIR/log-commit.py --repository "$REPOS" --revision "$REV"
+
+############################################################
+#
+# Mantisbt integration ( http://www.worldhello.net )
+#
+############################################################
+SVNLOOK=/usr/bin/svnlook
+SED=/bin/sed
+MANTISBT=/wwwroot/bugs/bugs
+PHP=/usr/bin/php
+
+if [ -f "$MANTISBT/core/checkin.php" ]; then
+ export LC_ALL=zh_CN.utf8
+ commitlog=`$SVNLOOK log -r "$REV" "$REPOS" | $SED -e 's/\$/\\\\n/g'`
+ commitdiff=`$SVNLOOK diff -r "$REV" "$REPOS" | head -25 | $SED -e 's/\$/\\\\n/g'`
+ echo -e "$commitlog\n\n****** Source code change ******\nRepository: $REPOS, Revision: $REV.\n\n$commitdiff" | $PHP -q $MANTISBT/core/checkin.php
+fi
\ No newline at end of file
已修改: trunk/doc/svn_hooks/hooks/pre-commit
===================================================================
--- trunk/doc/svn_hooks/hooks/pre-commit 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/pre-commit 2006-07-05 11:37:38 UTC (rev 27)
@@ -63,6 +63,7 @@
$TOOLS_DIR/commit_log_check.py "$REPOS" "$TXN" || exit 1
# New file must set svn:mime-type and svn:eol-style
+# $TOOLS_DIR/check-mime-type.pl "$REPOS" "$TXN" || exit 1
$TOOLS_DIR/check-mime-type.py "$REPOS" "$TXN" || exit 1
# Check for case conflicts
@@ -71,7 +72,7 @@
# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
-$TOOLS_DIR/svnperms.py -r "$REPOS" -t "$TXN" -f $TOOLS_DIR/svnperms.conf || exit 1
+# $TOOLS_DIR/svnperms.py -r "$REPOS" -t "$TXN" -f $TOOLS_DIR/svnperms.conf || exit 1
# All checks passed, so allow the commit.
exit 0
已修改: trunk/doc/svn_hooks/hooks/pre-commit.bat
===================================================================
--- trunk/doc/svn_hooks/hooks/pre-commit.bat 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/pre-commit.bat 2006-07-05 11:37:38 UTC (rev 27)
@@ -1,6 +1,3 @@
-
-echo on
-
REM SVN pre-commit hook for Windows
REM by Jiang Xin <worldhe...@gmail.com>
@@ -28,7 +25,6 @@
REM # the commit on the files and directories being modified.
REM %PYTHONCMD% %TOOLS_DIR%/svnperms.py -r "%REPOS%" -t "%TXN%" -f %TOOLS_DIR%/svnperms.conf || exit 1
-
REM # All checks passed, so allow the commit.
endlocal
exit 0
已修改: trunk/doc/svn_hooks/hooks/pre-commit.tmpl
===================================================================
--- trunk/doc/svn_hooks/hooks/pre-commit.tmpl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/pre-commit.tmpl 2006-07-05 11:37:38 UTC (rev 27)
@@ -64,13 +64,15 @@
# New file must set svn:mime-type and svn:eol-style
# $TOOLS_DIR/check-mime-type.pl "$REPOS" "$TXN" || exit 1
+$TOOLS_DIR/check-mime-type.py "$REPOS" "$TXN" || exit 1
# Check for case conflicts
-$TOOLS_DIR/check-case-insensitive.py "$REPOS" "$TXN" || exit 1
+$TOOLS_DIR/check-case-insensitive.pl "$REPOS" "$TXN" || exit 1
+#$TOOLS_DIR/check-case-insensitive.py "$REPOS" "$TXN" || exit 1
# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
-$TOOLS_DIR/svnperms.py -r "$REPOS" -t "$TXN" -f $TOOLS_DIR/svnperms.conf || exit 1
+# $TOOLS_DIR/svnperms.py -r "$REPOS" -t "$TXN" -f $TOOLS_DIR/svnperms.conf || exit 1
# All checks passed, so allow the commit.
exit 0
已修改: trunk/doc/svn_hooks/hooks/scripts/check-case-insensitive.pl
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/check-case-insensitive.pl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/check-case-insensitive.pl 2006-07-05 11:37:38 UTC (rev 27)
@@ -29,13 +29,13 @@
# It should list the file names which are in conflict. But it does stop the
# commit.
use encoding "utf8";
-$ENV{'LANG'} = 'zh_CN.utf8';
-$ENV{'LC_ALL'} = 'zh_CN.utf8';
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Please check the path to svnlook is correct...
my $svnlook;
if ($^O eq 'MSWin32') {
- $svnlook = '"c:\Program Files\subversion\bin\svnlook.exe"';
+ $svnlook = '"c:\\Program Files\\subversion\\bin\\svnlook.exe"';
} else {
$svnlook = '/usr/bin/svnlook';
}
@@ -56,7 +56,7 @@
#
# On a windows machine add this to pre-commit.bat:
#
-# perl <path-to-script>\check-case-insensitive.pl %1 %2
+# perl <path-to-script>\\check-case-insensitive.pl %1 %2
# if errorlevel 1 goto :ERROR
# exit 0
# :ERROR
已修改: trunk/doc/svn_hooks/hooks/scripts/check-mime-type.pl
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/check-mime-type.pl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/check-mime-type.pl 2006-07-05 11:37:38 UTC (rev 27)
@@ -42,8 +42,8 @@
# Svnlook path.
my $svnlook = "/usr/bin/svnlook";
-$ENV{'LANG'} = 'zh_CN.utf8';
-$ENV{'LC_ALL'} = 'zh_CN.utf8';
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Since the path to svnlook depends upon the local installation
# preferences, check that the required program exists to insure that
已修改: trunk/doc/svn_hooks/hooks/scripts/check-mime-type.py
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/check-mime-type.py 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/check-mime-type.py 2006-07-05 11:37:38 UTC (rev 27)
@@ -22,7 +22,7 @@
else:
SVNLOOK = '/usr/bin/svnlook'
-os.environ['LANG'] = os.environ['LC_ALL'] = 'zh_CN.utf8'
+os.environ['LANG'] = os.environ['LC_ALL'] = 'zh_CN.UTF8'
MIN_LENGTH = 5
已修改: trunk/doc/svn_hooks/hooks/scripts/commit-email.pl
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/commit-email.pl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/commit-email.pl 2006-07-05 11:37:38 UTC (rev 27)
@@ -23,8 +23,8 @@
$ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
-$ENV{'LANG'} = 'zh_CN.utf8';
-$ENV{'LC_ALL'} = 'zh_CN.utf8';
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Turn on warnings the best way depending on the Perl version.
BEGIN {
@@ -374,8 +374,19 @@
push(@body, "Log:\n");
push(@body, @log);
push(@body, "\n");
-push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
+my $lenlimit = 1000;
+my $len = scalar(@difflines)-1;
+my $body_extra = "";
+if ($len > $lenlimit)
+ {
+ $len = $lenlimit;
+ $body_extra = "\n... ...\n... ...\n" . (scalar(@difflines)-$len) . " more lines...\n... ...\n... ...\n";
+ }
+
+push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines[0..$len]);
+push(@body, $body_extra);
+
# Go through each project and see if there are any matches for this
# project. If so, send the log out.
foreach my $project (@project_settings_list)
已修改: trunk/doc/svn_hooks/hooks/scripts/commit-email.pl.in
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/commit-email.pl.in 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/commit-email.pl.in 2006-07-05 11:37:38 UTC (rev 27)
@@ -23,6 +23,8 @@
$ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Turn on warnings the best way depending on the Perl version.
BEGIN {
@@ -53,7 +55,7 @@
# prints the entire contents of the file. If you want to save space
# in the log and email messages by not printing the file, then set
# $no_diff_added to 1.
-my $no_diff_added = 1;
+my $no_diff_added = 0;
# End of Configuration section.
######################################################################
@@ -286,6 +288,7 @@
# Get the diff from svnlook.
my @no_diff_deleted = $no_diff_deleted ? ('--no-diff-deleted') : ();
+# Warning: svnlook 1.1.x not support --no-diff-added
my @no_diff_added = $no_diff_added ? ('--no-diff-added') : ();
my @difflines = &read_from_process($svnlook, 'diff', $repos,
'-r', $rev, @no_diff_deleted,
@@ -371,8 +374,19 @@
push(@body, "Log:\n");
push(@body, @log);
push(@body, "\n");
-push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines);
+my $lenlimit = 1000;
+my $len = scalar(@difflines)-1;
+my $body_extra = "";
+if ($len > $lenlimit)
+ {
+ $len = $lenlimit;
+ $body_extra = "\n... ...\n... ...\n" . (scalar(@difflines)-$len) . " more lines...\n... ...\n... ...\n";
+ }
+
+push(@body, map { /[\r\n]+$/ ? $_ : "$_\n" } @difflines[0..$len]);
+push(@body, $body_extra);
+
# Go through each project and see if there are any matches for this
# project. If so, send the log out.
foreach my $project (@project_settings_list)
已修改: trunk/doc/svn_hooks/hooks/scripts/commit_log_check.py
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/commit_log_check.py 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/commit_log_check.py 2006-07-05 11:37:38 UTC (rev 27)
@@ -18,7 +18,7 @@
else:
SVNLOOK = '/usr/bin/svnlook'
-os.environ['LANG'] = os.environ['LC_ALL'] = 'zh_CN.utf8'
+os.environ['LANG'] = os.environ['LC_ALL'] = 'zh_CN.UTF8'
MIN_LENGTH = 5
已修改: trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl 2006-07-05 11:37:38 UTC (rev 27)
@@ -23,8 +23,8 @@
# ====================================================================
$ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
-$ENV{'LANG'} = 'zh_CN.utf8';
-$ENV{'LC_ALL'} = 'zh_CN.utf8';
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Turn on warnings the best way depending on the Perl version.
BEGIN {
已修改: trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl.in
===================================================================
--- trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl.in 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/scripts/propchange-email.pl.in 2006-07-05 11:37:38 UTC (rev 27)
@@ -8,11 +8,6 @@
# For usage, see the usage subroutine or run the script with no
# command line arguments.
#
-# $HeadURL: http://svn.collab.net/repos/svn/branches/1.3.x/tools/hook-scripts/propchange-email.pl.in $
-# $LastChangedDate: 2004-06-14 22:29:22 +0200 (Mon, 14 Jun 2004) $
-# $LastChangedBy: breser $
-# $LastChangedRevision: 9986 $
-#
# ====================================================================
# Copyright (c) 2000-2004 CollabNet. All rights reserved.
#
@@ -28,6 +23,8 @@
# ====================================================================
$ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";
+$ENV{'LANG'} = 'zh_CN.UTF8';
+$ENV{'LC_ALL'} = 'zh_CN.UTF8';
# Turn on warnings the best way depending on the Perl version.
BEGIN {
已修改: trunk/doc/svn_hooks/hooks/start-commit
===================================================================
--- trunk/doc/svn_hooks/hooks/start-commit 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/start-commit 2006-07-05 11:37:38 UTC (rev 27)
@@ -56,7 +56,6 @@
# Characters in LOCK_FILE should be utf-8 format!
cat $LOCK_FILE >&2
else
- # echo "系统维护中,暂时禁止提交。" >&2
echo "Under maintenance, commit not allowed this time." 1>&2
fi
exit 1
@@ -74,7 +73,7 @@
# echo "$USER is not allowed to commit." >&2 && exit 1
#fi
-## 检查 repository 空间占用
+## check free space in repository
# MAX_SIZE=20480 # 20MB
# repos_size=`du -s $REPOS | cut -f 1`
#
已修改: trunk/doc/svn_hooks/hooks/start-commit.tmpl
===================================================================
--- trunk/doc/svn_hooks/hooks/start-commit.tmpl 2006-05-30 10:17:19 UTC (rev 26)
+++ trunk/doc/svn_hooks/hooks/start-commit.tmpl 2006-07-05 11:37:38 UTC (rev 27)
@@ -56,25 +56,24 @@
# Characters in LOCK_FILE should be utf-8 format!
cat $LOCK_FILE >&2
else
- # echo "系统维护中,暂时禁止提交。" >&2
echo "Under maintenance, commit not allowed this time." 1>&2
fi
exit 1
fi
-# anonymous commit not allowed
-if [ "x$USER" = "x" ]; then
- echo "You must login before you can commit." 1>&2
- exit 1
-fi
+## anonymous commit not allowed
+#if [ "x$USER" = "x" ]; then
+# echo "You must login before you can commit." 1>&2
+# exit 1
+#fi
-# check black_list
-if [ -s $BLACKLIST_FILE ]; then
- ( grep -v "^#" "$BLACKLIST_FILE" | grep -iwq "$USER" ) && \
- echo "$USER is not allowed to commit." >&2 && exit 1
-fi
+## check black_list
+#if [ -s $BLACKLIST_FILE -a ! -z "$USER" ]; then
+# ( grep -v "^#" "$BLACKLIST_FILE" | grep -iwq "$USER" ) && \
+# echo "$USER is not allowed to commit." >&2 && exit 1
+#fi
-## 检查 repository 空间占用
+## check free space in repository
# MAX_SIZE=20480 # 20MB
# repos_size=`du -s $REPOS | cut -f 1`
#