From 3a1ae6fee42a837fce92f91f264c1aa2b176191d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 14 May 2015 04:13:12 +0000 Subject: [PATCH] changed the post-commit script to use perl modules to get the revision author instead of executing svnlook --- codepot/etc/post-commit.in | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/codepot/etc/post-commit.in b/codepot/etc/post-commit.in index 616dacd2..fedc45c9 100644 --- a/codepot/etc/post-commit.in +++ b/codepot/etc/post-commit.in @@ -7,9 +7,13 @@ use DBI; use File::Basename; use POSIX qw(strftime); +use SVN::Core; +use SVN::Repos; +use SVN::Fs; + my $CFG_FILE = '@CFGDIR@/codepot.ini'; -my $REPO = $ARGV[0]; -my $REPOBASE = basename($REPO); +my $REPOFS = $ARGV[0]; +my $REPOBASE = basename($REPOFS); my $REV = $ARGV[1]; my $QC = ''; @@ -120,11 +124,38 @@ sub write_commit_log return (0, undef); } + +sub get_author +{ + my $pool = SVN::Pool->new(undef); + my $svn = eval { SVN::Repos::open ($REPOFS, $pool) }; + if (!defined($svn)) + { + print (STDERR "Cannot open svn - $REPOFS\n"); + return undef; + } + + my $fs = $svn->fs (); + if (!defined($fs)) + { + print (STDERR "Cannot open fs - $REPOFS\n"); + return undef; + } + + my $author = $fs->revision_prop ($REV, 'svn:author'); + return $author; +} + #------------------------------------------------------------ # MAIN #------------------------------------------------------------ -my $AUTHOR = `svnlook author -r "${REV}" "${REPO}"`; +my $AUTHOR = get_author(); +if (!defined($AUTHOR)) +{ + print (STDERR "Cannot get author for $REPOBASE $REV\n"); + exit (1); +} chomp ($AUTHOR); my $cfg = get_config ();