@@ -1211,13 +1211,13 @@ sub req_ci
12111211
12121212 chdir $tmpdir ;
12131213
1214- # populate the temporary index based
1214+ # populate the temporary index
12151215 system (" git-read-tree" , $parenthash );
12161216 unless ($? == 0)
12171217 {
12181218 die " Error running git-read-tree $state ->{module} $file_index $! " ;
12191219 }
1220- $log -> info(" Created index '$file_index ' with for head $state ->{module} - exit status $? " );
1220+ $log -> info(" Created index '$file_index ' for head $state ->{module} - exit status $? " );
12211221
12221222 my @committedfiles = ();
12231223 my %oldmeta ;
@@ -1237,7 +1237,7 @@ sub req_ci
12371237
12381238 my ( $filepart , $dirpart ) = filenamesplit($filename );
12391239
1240- # do a checkout of the file if it part of this tree
1240+ # do a checkout of the file if it is part of this tree
12411241 if ($wrev ) {
12421242 system (' git-checkout-index' , ' -f' , ' -u' , $filename );
12431243 unless ($? == 0) {
@@ -1324,11 +1324,11 @@ sub req_ci
13241324 exit ;
13251325 }
13261326
1327- # Check that this is allowed, just as we would with a receive-pack
1328- my @cmd = ( $ENV {GIT_DIR }.' hooks/update' , " refs/heads/$state ->{module}" ,
1327+ # ## Emulate git- receive-pack by running hooks/update
1328+ my @hook = ( $ENV {GIT_DIR }.' hooks/update' , " refs/heads/$state ->{module}" ,
13291329 $parenthash , $commithash );
1330- if ( -x $cmd [0] ) {
1331- unless ( system ( @cmd ) == 0 )
1330+ if ( -x $hook [0] ) {
1331+ unless ( system ( @hook ) == 0 )
13321332 {
13331333 $log -> warn (" Commit failed (update hook declined to update ref)" );
13341334 print " error 1 Commit failed (update hook declined)\n " ;
@@ -1337,13 +1337,32 @@ sub req_ci
13371337 }
13381338 }
13391339
1340+ # ## Update the ref
13401341 if (system (qw( git update-ref -m) , " cvsserver ci" ,
13411342 " refs/heads/$state ->{module}" , $commithash , $parenthash )) {
13421343 $log -> warn (" update-ref for $state ->{module} failed." );
13431344 print " error 1 Cannot commit -- update first\n " ;
13441345 exit ;
13451346 }
13461347
1348+ # ## Emulate git-receive-pack by running hooks/post-receive
1349+ my $hook = $ENV {GIT_DIR }.' hooks/post-receive' ;
1350+ if ( -x $hook ) {
1351+ open (my $pipe , " | $hook " ) || die " can't fork $! " ;
1352+
1353+ local $SIG {PIPE } = sub { die ' pipe broke' };
1354+
1355+ print $pipe " $parenthash $commithash refs/heads/$state ->{module}\n " ;
1356+
1357+ close $pipe || die " bad pipe: $! $? " ;
1358+ }
1359+
1360+ # ## Then hooks/post-update
1361+ $hook = $ENV {GIT_DIR }.' hooks/post-update' ;
1362+ if (-x $hook ) {
1363+ system ($hook , " refs/heads/$state ->{module}" );
1364+ }
1365+
13471366 $updater -> update();
13481367
13491368 # foreach file specified on the command line ...
0 commit comments