rewrote the post-revprop-change script in perl
This commit is contained in:
parent
13735ac2b4
commit
e23e23d592
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/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"
|
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 etc/post-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
|
||||||
@ -3079,6 +3079,7 @@ do
|
|||||||
"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" ;;
|
||||||
|
"etc/post-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/post-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" ;;
|
||||||
"DEBIAN/postinst" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/postinst" ;;
|
"DEBIAN/postinst" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/postinst" ;;
|
||||||
|
@ -89,6 +89,7 @@ AC_CONFIG_FILES([
|
|||||||
etc/start-commit
|
etc/start-commit
|
||||||
etc/post-commit
|
etc/post-commit
|
||||||
etc/pre-revprop-change
|
etc/pre-revprop-change
|
||||||
|
etc/post-revprop-change
|
||||||
DEBIAN/Makefile
|
DEBIAN/Makefile
|
||||||
DEBIAN/control
|
DEBIAN/control
|
||||||
DEBIAN/postinst
|
DEBIAN/postinst
|
||||||
|
@ -38,8 +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)/post-commit.in $(srcdir)/pre-revprop-change.in \
|
$(srcdir)/post-commit.in $(srcdir)/post-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 \
|
||||||
$(top_srcdir)/configure.ac
|
$(top_srcdir)/configure.ac
|
||||||
@ -48,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 \
|
||||||
post-commit pre-revprop-change
|
post-commit pre-revprop-change post-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)
|
||||||
@ -195,6 +195,8 @@ post-commit: $(top_builddir)/config.status $(srcdir)/post-commit.in
|
|||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
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)/$@
|
||||||
|
post-revprop-change: $(top_builddir)/config.status $(srcdir)/post-revprop-change.in
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||||
install-cfgSCRIPTS: $(cfg_SCRIPTS)
|
install-cfgSCRIPTS: $(cfg_SCRIPTS)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
test -z "$(cfgdir)" || $(mkdir_p) "$(DESTDIR)$(cfgdir)"
|
test -z "$(cfgdir)" || $(mkdir_p) "$(DESTDIR)$(cfgdir)"
|
||||||
|
@ -69,7 +69,6 @@ sub write_commit_log
|
|||||||
my $message = "svn,$projectid,$revision";
|
my $message = "svn,$projectid,$revision";
|
||||||
my $createdon = strftime ('%Y-%m-%d %H:%M:%S', localtime());
|
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(?,?,?,?,?,?)");
|
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))
|
if (!$query || !$query->execute ('code', $projectid, $message, $createdon, 'commit', $userid))
|
||||||
{
|
{
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
REPOBASE="`basename "${1}"`"
|
|
||||||
REVISION="${2}"
|
|
||||||
USER="${3}"
|
|
||||||
PROPNAME="${4}"
|
|
||||||
ACTION="${5}"
|
|
||||||
|
|
||||||
# [STDIN] PROPVAL ** the old property value is passed via STDIN.
|
|
||||||
|
|
||||||
# does not care if logging has failed.
|
|
||||||
wget -q -O- "%API%/logCodeRevpropChange/svn/${REPOBASE}/${REVISION}/${USER}/${PROPNAME}/${ACTION}" 2>/dev/null
|
|
||||||
exit 0
|
|
119
codepot/etc/post-revprop-change.in
Normal file
119
codepot/etc/post-revprop-change.in
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
#!/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];
|
||||||
|
my $USER = $ARGV[2];
|
||||||
|
my $PROPNAME = $ARGV[3];
|
||||||
|
my $ACTION = $ARGV[4];
|
||||||
|
|
||||||
|
REPOBASE="`basename "${1}"`"
|
||||||
|
REVISION="${2}"
|
||||||
|
USER="${3}"
|
||||||
|
PROPNAME="${4}"
|
||||||
|
ACTION="${5}"
|
||||||
|
|
||||||
|
# [STDIN] PROPVAL ** the old property value is passed via STDIN.
|
||||||
|
|
||||||
|
#wget -q -O- "%API%/logCodeRevpropChange/svn/${REPOBASE}/${REVISION}/${USER}/${PROPNAME}/${ACTION}" 2>/dev/null
|
||||||
|
#exit 0
|
||||||
|
|
||||||
|
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_revprop_change_log
|
||||||
|
{
|
||||||
|
my ($dbh, $prefix, $projectid, $revision, $userid, $propname, $action) = @_;
|
||||||
|
|
||||||
|
#+------+---------+-----------+---------------------------+---------------------+---------------+-----------------+
|
||||||
|
#| id | type | projectid | message | createdon | action | userid |
|
||||||
|
#+------+---------+-----------+---------------------------+---------------------+---------------+-----------------+
|
||||||
|
#| 1610 | code | codepot | svn,codepot,98,svn:log,M | 2014-05-16 22:27:36 | revpropchange | hyunghwan.chung |
|
||||||
|
|
||||||
|
my $message = "svn,$projectid,$revision,$propname,$action";
|
||||||
|
my $createdon = strftime ('%Y-%m-%d %H:%M:%S', localtime());
|
||||||
|
|
||||||
|
my $query = $dbh->prepare ("INSERT INTO ${prefix}log(type,projectid,message,createdon,action,userid) VALUES(?,?,?,?,?,?)");
|
||||||
|
if (!$query || !$query->execute ('code', $projectid, $message, $createdon, 'revpropchange', $userid))
|
||||||
|
{
|
||||||
|
$dbh->rollback ();
|
||||||
|
return (-1, $dbh->errstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
$dbh->commit ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
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_revprop_change_log ($dbh, $cfg->{database_prefix}, $REPOBASE, $REV, $USER, $PROPNAME, $ACTION);
|
||||||
|
close_database ($dbh);
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user