rewrote the post-commit script in perl
This commit is contained in:
parent
124632ba8a
commit
13735ac2b4
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/start-commit etc/pre-revprop-change 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/start-commit etc/post-commit etc/pre-revprop-change 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/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/pre-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/pre-revprop-change" ;;
|
"etc/pre-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/pre-revprop-change" ;;
|
||||||
"DEBIAN/Makefile" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/Makefile" ;;
|
"DEBIAN/Makefile" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/Makefile" ;;
|
||||||
"DEBIAN/control" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/control" ;;
|
"DEBIAN/control" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/control" ;;
|
||||||
|
@ -87,6 +87,7 @@ AC_CONFIG_FILES([
|
|||||||
etc/codepot.ini
|
etc/codepot.ini
|
||||||
etc/codepot.a2ldap
|
etc/codepot.a2ldap
|
||||||
etc/start-commit
|
etc/start-commit
|
||||||
|
etc/post-commit
|
||||||
etc/pre-revprop-change
|
etc/pre-revprop-change
|
||||||
DEBIAN/Makefile
|
DEBIAN/Makefile
|
||||||
DEBIAN/control
|
DEBIAN/control
|
||||||
|
@ -38,7 +38,8 @@ POST_UNINSTALL = :
|
|||||||
subdir = etc
|
subdir = etc
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||||
$(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.ini.in \
|
$(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.ini.in \
|
||||||
$(srcdir)/pre-revprop-change.in $(srcdir)/start-commit.in
|
$(srcdir)/post-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 \
|
||||||
$(top_srcdir)/configure.ac
|
$(top_srcdir)/configure.ac
|
||||||
@ -47,7 +48,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 start-commit \
|
CONFIG_CLEAN_FILES = codepot.ini codepot.a2ldap start-commit \
|
||||||
pre-revprop-change
|
post-commit pre-revprop-change
|
||||||
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" \
|
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" \
|
||||||
"$(DESTDIR)$(cfgdir)"
|
"$(DESTDIR)$(cfgdir)"
|
||||||
cfgSCRIPT_INSTALL = $(INSTALL_SCRIPT)
|
cfgSCRIPT_INSTALL = $(INSTALL_SCRIPT)
|
||||||
@ -190,6 +191,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)/$@
|
||||||
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
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
pre-revprop-change: $(top_builddir)/config.status $(srcdir)/pre-revprop-change.in
|
pre-revprop-change: $(top_builddir)/config.status $(srcdir)/pre-revprop-change.in
|
||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
install-cfgSCRIPTS: $(cfg_SCRIPTS)
|
install-cfgSCRIPTS: $(cfg_SCRIPTS)
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
REPOBASE="`basename "${1}"`"
|
|
||||||
REV="${2}"
|
|
||||||
|
|
||||||
AUTHOR="`svnlook author -r ${REV} "${1}"`"
|
|
||||||
|
|
||||||
# does not care if logging has failed.
|
|
||||||
wget -q -O- "%API%/logCodeCommit/svn/${REPOBASE}/${REV}/${AUTHOR}" 2>/dev/null
|
|
||||||
exit 0
|
|
109
codepot/etc/post-commit.in
Normal file
109
codepot/etc/post-commit.in
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use Config::Simple;
|
||||||
|
use DBI;
|
||||||
|
use File::Basename;
|
||||||
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
|
my $CFG_FILE = '@CFGDIR@/codepot.ini';
|
||||||
|
my $REPO = $ARGV[0];
|
||||||
|
my $REPOBASE = basename($REPO);
|
||||||
|
my $REV = $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")
|
||||||
|
};
|
||||||
|
|
||||||
|
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 write_commit_log
|
||||||
|
{
|
||||||
|
my ($dbh, $prefix, $projectid, $revision, $userid) = @_;
|
||||||
|
|
||||||
|
#+------+---------+-----------+---------------------------+---------------------+---------------+-----------------+
|
||||||
|
#| id | type | projectid | message | createdon | action | userid |
|
||||||
|
#+------+---------+-----------+---------------------------+---------------------+---------------+-----------------+
|
||||||
|
#| 895 | code | codepot | svn,codepot,72 | 2011-10-10 14:26:43 | commit | hyunghwan.chung |
|
||||||
|
|
||||||
|
my $message = "svn,$projectid,$revision";
|
||||||
|
my $createdon = strftime ('%Y-%m-%d %H:%M:%S', localtime());
|
||||||
|
|
||||||
|
print ("INSERT INTO ${prefix}log(type,projectid,message,createdon,action,userid) VALUES(?,?,?,?,?,? $createdon $message)\n");
|
||||||
|
my $query = $dbh->prepare ("INSERT INTO ${prefix}log(type,projectid,message,createdon,action,userid) VALUES(?,?,?,?,?,?)");
|
||||||
|
if (!$query || !$query->execute ('code', $projectid, $message, $createdon, 'commit', $userid))
|
||||||
|
{
|
||||||
|
$dbh->rollback ();
|
||||||
|
return (-1, $dbh->errstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbh->commit ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
my $AUTHOR = `svnlook author -r "${REV}" "${REPO}"`;
|
||||||
|
chomp ($AUTHOR);
|
||||||
|
|
||||||
|
my $cfg = get_config ();
|
||||||
|
if (!defined($cfg))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot load codepot configuration file\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $dbh = open_database ($cfg);
|
||||||
|
if (!defined($dbh))
|
||||||
|
{
|
||||||
|
print (STDERR "Cannot open database\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
write_commit_log ($dbh, $cfg->{database_prefix}, $REPOBASE, $REV, $AUTHOR);
|
||||||
|
close_database ($dbh);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user