rewritten pre-commit and added svn_min_commit_message_length
This commit is contained in:
parent
1eb3334f65
commit
b448ee94e5
3
codepot/configure
vendored
3
codepot/configure
vendored
@ -2544,7 +2544,7 @@ cachedir=$cachedir
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile codepot.spec etc/Makefile etc/codepot.ini etc/codepot.a2ldap etc/codepot.httpd etc/start-commit etc/post-commit etc/pre-revprop-change etc/post-revprop-change sbin/Makefile sbin/codepot-user DEBIAN/Makefile DEBIAN/control DEBIAN/postinst DEBIAN/postrm src/config.php src/codepot/config/Makefile src/codepot/controllers/Makefile src/codepot/errors/Makefile src/codepot/helpers/Makefile src/codepot/hooks/Makefile src/codepot/language/english/Makefile src/codepot/language/indonesian/Makefile src/codepot/language/korean/Makefile src/codepot/language/Makefile src/codepot/libraries/Makefile src/codepot/models/Makefile src/codepot/views/Makefile src/codepot/Makefile src/css/images/Makefile src/css/Makefile src/js/prettify/Makefile src/js/Makefile src/system/cache/Makefile src/system/codeigniter/Makefile src/system/database/drivers/mssql/Makefile src/system/database/drivers/mysql/Makefile src/system/database/drivers/mysqli/Makefile src/system/database/drivers/oci8/Makefile src/system/database/drivers/odbc/Makefile src/system/database/drivers/postgre/Makefile src/system/database/drivers/sqlite/Makefile src/system/database/drivers/Makefile src/system/database/Makefile src/system/fonts/Makefile src/system/helpers/Makefile src/system/language/english/Makefile src/system/language/korean/Makefile src/system/language/Makefile src/system/libraries/Makefile src/system/logs/Makefile src/system/plugins/Makefile src/system/scaffolding/images/Makefile src/system/scaffolding/views/Makefile src/system/scaffolding/Makefile src/system/Makefile src/Makefile"
|
ac_config_files="$ac_config_files Makefile codepot.spec etc/Makefile etc/codepot.ini etc/codepot.a2ldap etc/codepot.httpd etc/pre-commit etc/start-commit etc/post-commit etc/pre-revprop-change etc/post-revprop-change sbin/Makefile sbin/codepot-user DEBIAN/Makefile DEBIAN/control DEBIAN/postinst DEBIAN/postrm src/config.php src/codepot/config/Makefile src/codepot/controllers/Makefile src/codepot/errors/Makefile src/codepot/helpers/Makefile src/codepot/hooks/Makefile src/codepot/language/english/Makefile src/codepot/language/indonesian/Makefile src/codepot/language/korean/Makefile src/codepot/language/Makefile src/codepot/libraries/Makefile src/codepot/models/Makefile src/codepot/views/Makefile src/codepot/Makefile src/css/images/Makefile src/css/Makefile src/js/prettify/Makefile src/js/Makefile src/system/cache/Makefile src/system/codeigniter/Makefile src/system/database/drivers/mssql/Makefile src/system/database/drivers/mysql/Makefile src/system/database/drivers/mysqli/Makefile src/system/database/drivers/oci8/Makefile src/system/database/drivers/odbc/Makefile src/system/database/drivers/postgre/Makefile src/system/database/drivers/sqlite/Makefile src/system/database/drivers/Makefile src/system/database/Makefile src/system/fonts/Makefile src/system/helpers/Makefile src/system/language/english/Makefile src/system/language/korean/Makefile src/system/language/Makefile src/system/libraries/Makefile src/system/logs/Makefile src/system/plugins/Makefile src/system/scaffolding/images/Makefile src/system/scaffolding/views/Makefile src/system/scaffolding/Makefile src/system/Makefile src/Makefile"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# This file is a shell script that caches the results of configure
|
||||||
@ -3077,6 +3077,7 @@ do
|
|||||||
"etc/codepot.ini" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.ini" ;;
|
"etc/codepot.ini" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.ini" ;;
|
||||||
"etc/codepot.a2ldap" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.a2ldap" ;;
|
"etc/codepot.a2ldap" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.a2ldap" ;;
|
||||||
"etc/codepot.httpd" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.httpd" ;;
|
"etc/codepot.httpd" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.httpd" ;;
|
||||||
|
"etc/pre-commit" ) CONFIG_FILES="$CONFIG_FILES etc/pre-commit" ;;
|
||||||
"etc/start-commit" ) CONFIG_FILES="$CONFIG_FILES etc/start-commit" ;;
|
"etc/start-commit" ) CONFIG_FILES="$CONFIG_FILES etc/start-commit" ;;
|
||||||
"etc/post-commit" ) CONFIG_FILES="$CONFIG_FILES etc/post-commit" ;;
|
"etc/post-commit" ) CONFIG_FILES="$CONFIG_FILES etc/post-commit" ;;
|
||||||
"etc/pre-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/pre-revprop-change" ;;
|
"etc/pre-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/pre-revprop-change" ;;
|
||||||
|
@ -87,6 +87,7 @@ AC_CONFIG_FILES([
|
|||||||
etc/codepot.ini
|
etc/codepot.ini
|
||||||
etc/codepot.a2ldap
|
etc/codepot.a2ldap
|
||||||
etc/codepot.httpd
|
etc/codepot.httpd
|
||||||
|
etc/pre-commit
|
||||||
etc/start-commit
|
etc/start-commit
|
||||||
etc/post-commit
|
etc/post-commit
|
||||||
etc/pre-revprop-change
|
etc/pre-revprop-change
|
||||||
|
@ -39,7 +39,7 @@ subdir = etc
|
|||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||||
$(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.httpd.in \
|
$(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.httpd.in \
|
||||||
$(srcdir)/codepot.ini.in $(srcdir)/post-commit.in \
|
$(srcdir)/codepot.ini.in $(srcdir)/post-commit.in \
|
||||||
$(srcdir)/post-revprop-change.in \
|
$(srcdir)/post-revprop-change.in $(srcdir)/pre-commit.in \
|
||||||
$(srcdir)/pre-revprop-change.in $(srcdir)/start-commit.in
|
$(srcdir)/pre-revprop-change.in $(srcdir)/start-commit.in
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/as-ac-expand.m4 \
|
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/as-ac-expand.m4 \
|
||||||
@ -49,7 +49,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
|||||||
mkinstalldirs = $(install_sh) -d
|
mkinstalldirs = $(install_sh) -d
|
||||||
CONFIG_HEADER = $(top_builddir)/./config.h
|
CONFIG_HEADER = $(top_builddir)/./config.h
|
||||||
CONFIG_CLEAN_FILES = codepot.ini codepot.a2ldap codepot.httpd \
|
CONFIG_CLEAN_FILES = codepot.ini codepot.a2ldap codepot.httpd \
|
||||||
start-commit post-commit pre-revprop-change \
|
pre-commit start-commit post-commit pre-revprop-change \
|
||||||
post-revprop-change
|
post-revprop-change
|
||||||
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" \
|
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" \
|
||||||
"$(DESTDIR)$(cfgdir)"
|
"$(DESTDIR)$(cfgdir)"
|
||||||
@ -193,6 +193,8 @@ codepot.a2ldap: $(top_builddir)/config.status $(srcdir)/codepot.a2ldap.in
|
|||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
codepot.httpd: $(top_builddir)/config.status $(srcdir)/codepot.httpd.in
|
codepot.httpd: $(top_builddir)/config.status $(srcdir)/codepot.httpd.in
|
||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
|
pre-commit: $(top_builddir)/config.status $(srcdir)/pre-commit.in
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
start-commit: $(top_builddir)/config.status $(srcdir)/start-commit.in
|
start-commit: $(top_builddir)/config.status $(srcdir)/start-commit.in
|
||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
post-commit: $(top_builddir)/config.status $(srcdir)/post-commit.in
|
post-commit: $(top_builddir)/config.status $(srcdir)/post-commit.in
|
||||||
|
@ -195,6 +195,12 @@ signin_for_code_search = "yes"
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
svn_read_access = "member"
|
svn_read_access = "member"
|
||||||
|
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; The length of a commit message must be as long as this value.
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
svn_min_commit_message_length = "0"
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; customized footer
|
; customized footer
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
REPO="$1"
|
|
||||||
TXN="$2"
|
|
||||||
|
|
||||||
# TODO: need to check the policy on a commit message
|
|
||||||
# wget ... %API%/svnPolicy/ ...
|
|
||||||
# once done, update repo.sh to include pre-commit
|
|
||||||
|
|
||||||
svnlook log -t "$TXN" "$REPO" | grep "[a-zA-Z0-9]" >/dev/null || {
|
|
||||||
echo "---------------------------------------------------------" >&2
|
|
||||||
echo " Your commit message do not contain any meaningful text. " >&2
|
|
||||||
echo "---------------------------------------------------------" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Subversion problem:
|
|
||||||
# Hard to detect the tagging patterns and update patterns on a tag.
|
|
||||||
#
|
|
||||||
#svnlook changed -t "$TXN" "$REPO" | grep '^tags/' >/dev/null && {
|
|
||||||
# echo "----------------------------------------------------" >&2
|
|
||||||
# echo " You are not allowed to change tags/* " >&2
|
|
||||||
# echo "----------------------------------------------------" >&2
|
|
||||||
# exit 1
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
|
|
||||||
exit 0
|
|
182
codepot/etc/pre-commit.in
Normal file
182
codepot/etc/pre-commit.in
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use Config::Simple;
|
||||||
|
use DBI;
|
||||||
|
use File::Basename;
|
||||||
|
|
||||||
|
use SVN::Core;
|
||||||
|
use SVN::Repos;
|
||||||
|
use SVN::Fs;
|
||||||
|
|
||||||
|
my $CFG_FILE = '@CFGDIR@/codepot.ini';
|
||||||
|
my $REPOFS = $ARGV[0];
|
||||||
|
my $REPOBASE = basename($REPOFS);
|
||||||
|
my $TRANSACTION = $ARGV[1];
|
||||||
|
|
||||||
|
sub get_config
|
||||||
|
{
|
||||||
|
my $cfg = new Config::Simple();
|
||||||
|
|
||||||
|
if (!$cfg->read ($CFG_FILE))
|
||||||
|
{
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $config = {
|
||||||
|
database_hostname => $cfg->param ('database_hostname'),
|
||||||
|
database_username => $cfg->param ('database_username'),
|
||||||
|
database_password => $cfg->param ('database_password'),
|
||||||
|
database_name => $cfg->param ('database_name'),
|
||||||
|
database_driver => $cfg->param ('database_driver'),
|
||||||
|
database_prefix => $cfg->param ('database_prefix'),
|
||||||
|
|
||||||
|
svn_min_commit_message_length => $cfg->param ('svn_min_commit_message_length')
|
||||||
|
};
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub open_database
|
||||||
|
{
|
||||||
|
my ($cfg) = @_;
|
||||||
|
|
||||||
|
my $dbtype = $cfg->{database_driver};
|
||||||
|
my $dbname = $cfg->{database_name};
|
||||||
|
my $dbhost = $cfg->{database_hostname};
|
||||||
|
|
||||||
|
my $dbh = DBI->connect(
|
||||||
|
"DBI:$dbtype:$dbname:$dbhost",
|
||||||
|
$cfg->{database_username},
|
||||||
|
$cfg->{database_password},
|
||||||
|
{ RaiseError => 0, PrintError => 0, AutoCommit => 0 }
|
||||||
|
);
|
||||||
|
|
||||||
|
return $dbh;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub close_database
|
||||||
|
{
|
||||||
|
my ($dbh) = @_;
|
||||||
|
$dbh->disconnect ();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub is_project_member
|
||||||
|
{
|
||||||
|
my ($dbh, $prefix, $projectid, $userid) = @_;
|
||||||
|
|
||||||
|
my $query = $dbh->prepare ("SELECT projectid FROM ${prefix}project_membership WHERE userid=? AND projectid=?");
|
||||||
|
if (!$query || !$query->execute ($userid, $projectid))
|
||||||
|
{
|
||||||
|
return (-1, $dbh->errstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
my @row = $query->fetchrow_array;
|
||||||
|
$query->finish ();
|
||||||
|
return (((scalar(@row) > 0)? 1: 0), undef);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub is_project_commitable
|
||||||
|
{
|
||||||
|
my ($dbh, $prefix, $projectid) = @_;
|
||||||
|
|
||||||
|
my $query = $dbh->prepare ("SELECT commitable FROM ${prefix}project WHERE id=?");
|
||||||
|
if (!$query || !$query->execute ($projectid))
|
||||||
|
{
|
||||||
|
return (-1, $dbh->errstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
my @row = $query->fetchrow_array;
|
||||||
|
$query->finish ();
|
||||||
|
return (((scalar(@row) > 0 && $row[0] eq 'Y')? 1: 0), undef);
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
my $cfg = get_config ();
|
||||||
|
if (!defined($cfg))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot load codepot configuration file\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $pool = SVN::Pool->new(undef);
|
||||||
|
#my $config = SVN::Core::config_get_config(undef);
|
||||||
|
#my $fs = eval { SVN::Fs::open ($REPOFS, $config, $pool) };
|
||||||
|
my $svn = eval { SVN::Repos::open ($REPOFS, $pool) };
|
||||||
|
if (!defined($svn))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot open svn - $REPOFS\n");
|
||||||
|
exit (0); # just let go if the file system can't be opened
|
||||||
|
}
|
||||||
|
|
||||||
|
my $fs = $svn->fs ();
|
||||||
|
if (!defined($fs))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot open fs - $REPOFS\n");
|
||||||
|
exit (0); # just let go if the file system can't be opened
|
||||||
|
}
|
||||||
|
|
||||||
|
my $txn = eval { $fs->open_txn ($TRANSACTION) };
|
||||||
|
if (!defined($txn))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot open transaction - $TRANSACTION\n");
|
||||||
|
exit (0); # just let go if the transation can't be opened
|
||||||
|
}
|
||||||
|
|
||||||
|
my $log = $txn->prop ('svn:log');
|
||||||
|
$log =~ s/^\s+|\s+$//g; # trim leading spaces and trailing spaces
|
||||||
|
if (length($log) < $cfg->{svn_min_commit_message_length}) {
|
||||||
|
print (STDERR "Commit message too short. must be >= $cfg->{svn_min_commit_message_length}\n");
|
||||||
|
exit (1); # block
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#my $dbh = open_database ($cfg);
|
||||||
|
#if (!defined($dbh))
|
||||||
|
#{
|
||||||
|
# print (STDERR "Cannot open database\n");
|
||||||
|
# exit (1);
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#my $member;
|
||||||
|
#my $commitable;
|
||||||
|
#my $errstr;
|
||||||
|
#
|
||||||
|
#($member, $errstr) = is_project_member (
|
||||||
|
# $dbh, $cfg->{database_prefix}, $REPOBASE, $USER);
|
||||||
|
#if ($member <= -1)
|
||||||
|
#{
|
||||||
|
# print (STDERR "Cannot check membership - $errstr\n");
|
||||||
|
# close_database ($dbh);
|
||||||
|
# exit (1);
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#($commitable, $errstr) = is_project_commitable (
|
||||||
|
# $dbh, $cfg->{database_prefix}, $REPOBASE);
|
||||||
|
#if ($commitable <= -1)
|
||||||
|
#{
|
||||||
|
# print (STDERR "Cannot check commitability - $errstr\n");
|
||||||
|
# close_database ($dbh);
|
||||||
|
# exit (1);
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#close_database ($dbh);
|
||||||
|
#
|
||||||
|
#if ($member == 0)
|
||||||
|
#{
|
||||||
|
# print (STDERR "$USER doesn't belong to the $REPOBASE project\n");
|
||||||
|
# exit (1);
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#if ($commitable == 0)
|
||||||
|
#{
|
||||||
|
# print (STDERR "The $REPOBASE project is not commitable\n");
|
||||||
|
# exit (1);
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
exit (0);
|
Loading…
Reference in New Issue
Block a user