BSD compat changes

thanks to milki for all the efforts!

Details:

  - partial-copy fell afoul of BSD not having $RANDOM
  - test suite: fix bad GNU sort with good perl sort
  - test suite: fix md5sum dependency (which BSD doesn't have or can't
    easily have or requires extra options or whatever...), by doing it
    in perl.  (Requires Digest::MD5, which is probably available
    anyway, but since this is only for the test suite, meh!)
redis
Sitaram Chamarty 2012-04-28 12:03:32 +05:30
parent e919a0b7ca
commit 48ed4deb8f
8 changed files with 58 additions and 40 deletions

View File

@ -121,6 +121,9 @@ Here's how:
- VREF/partial-copy = @all - VREF/partial-copy = @all
config gitolite.partialCopyOf = foo config gitolite.partialCopyOf = foo
**IMPORTANT**: if you're using other VREFs, please make sure this one is
placed at the end, after all the others.
And that should be it. **Please test it and let me know if it doesn't work!** And that should be it. **Please test it and let me know if it doesn't work!**
WARNINGS: WARNINGS:

View File

@ -20,13 +20,13 @@ exec >&2
main=`git config --file $GL_REPO_BASE/$repo.git/config --get gitolite.partialCopyOf`; main=`git config --file $GL_REPO_BASE/$repo.git/config --get gitolite.partialCopyOf`;
[ -z "$main" ] && exit 0 [ -z "$main" ] && exit 0
rand=$RANDOM rand=$$
export GL_BYPASS_ACCESS_CHECKS=1 export GL_BYPASS_ACCESS_CHECKS=1
git push -f $GL_REPO_BASE/$main.git $new:refs/heads/br-$rand || die "FATAL: failed to send $new" git push -f $GL_REPO_BASE/$main.git $new:refs/partial/br-$rand || die "FATAL: failed to send $new"
cd $GL_REPO_BASE/$main.git cd $GL_REPO_BASE/$main.git
git update-ref -d refs/heads/br-$rand git update-ref -d refs/partial/br-$rand
git update-ref $ref $new $old || die "FATAL: update-ref for $ref failed" git update-ref $ref $new $old || die "FATAL: update-ref for $ref failed"
exit 0 exit 0

View File

@ -8,15 +8,18 @@ package Gitolite::Test;
try try
put put
text text
lines
dump dump
confreset confreset
confadd confadd
cmp cmp
md5sum
); );
#>>> #>>>
use Exporter 'import'; use Exporter 'import';
use File::Path qw(mkpath); use File::Path qw(mkpath);
use Carp qw(carp cluck croak confess); use Carp qw(carp cluck croak confess);
use Digest::MD5 qw(md5_hex);
use Gitolite::Common; use Gitolite::Common;
@ -25,6 +28,7 @@ BEGIN {
*{'try'} = \&Tsh::try; *{'try'} = \&Tsh::try;
*{'put'} = \&Tsh::put; *{'put'} = \&Tsh::put;
*{'text'} = \&Tsh::text; *{'text'} = \&Tsh::text;
*{'lines'} = \&Tsh::lines;
*{'cmp'} = \&Tsh::cmp; *{'cmp'} = \&Tsh::cmp;
} }
@ -100,4 +104,12 @@ sub confadd {
put "|cat >> conf/$file", $string; put "|cat >> conf/$file", $string;
} }
sub md5sum {
my $out = '';
for my $file (@_) {
$out .= md5_hex(slurp($file)) . " $file\n";
}
return $out;
}
1; 1;

View File

@ -473,9 +473,9 @@ sub fail {
} }
sub cmp { sub cmp {
# compare input string with text() # compare input string with second input string or text()
my $text = text();
my $in = shift; my $in = shift;
my $text = ( @_ ? +shift : text() );
if ( $text eq $in ) { if ( $text eq $in ) {
ok(); ok();

View File

@ -32,7 +32,7 @@ try "
glt clone u1 file://aa u1aa; ok; /Cloning into 'u1aa'.../ glt clone u1 file://aa u1aa; ok; /Cloning into 'u1aa'.../
/warning: You appear to have cloned an empty repository/ /warning: You appear to have cloned an empty repository/
ls -ald --time-style=long-iso u1aa; ls -ald --time-style=long-iso u1aa;
ok; /drwxr-xr-x 3 $ENV{USER} $ENV{USER} 4096 201.-..-.. ..:.. u1aa/ ok; /drwxr-xr-x 3 $ENV{USER} $ENV{USER} \\d+ 201.-..-.. ..:.. u1aa/
# basic clone deny # basic clone deny
glt clone u4 file://aa u4aa; !ok; /R any aa u4 DENIED by fallthru/ glt clone u4 file://aa u4aa; !ok; /R any aa u4 DENIED by fallthru/

View File

@ -59,13 +59,14 @@ try "
# now check the various files that should have been produced # now check the various files that should have been produced
try "cd $rb; find . -name gl-perms | sort | xargs md5sum"; cmp my $t;
try "cd $rb; find . -name gl-perms"; $t = md5sum(sort (lines())); cmp $t,
'59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms '59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1e.git/gl-perms 59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1e.git/gl-perms
'; ';
try "cd $rb; find . -name gl-creator | sort | xargs md5sum"; cmp try "cd $rb; find . -name gl-creator"; $t = md5sum(sort (lines())); cmp $t,
'346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1a2.git/gl-creator 'e4774cdda0793f86414e8b9140bb6db4 ./foo/u1/u1a.git/gl-creator
e4774cdda0793f86414e8b9140bb6db4 ./foo/u1/u1a.git/gl-creator 346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1a2.git/gl-creator
346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1e.git/gl-creator 346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1e.git/gl-creator
'; ';

View File

@ -15,6 +15,8 @@ try "pwd";
my $od = text(); my $od = text();
chomp($od); chomp($od);
my $t; # temp
# try an invalid config key # try an invalid config key
confreset;confadd ' confreset;confadd '
@ -62,13 +64,15 @@ try "ADMIN_PUSH set1; !/FATAL/" or die text();
my $rb = `gitolite query-rc -n GL_REPO_BASE`; my $rb = `gitolite query-rc -n GL_REPO_BASE`;
try " try "
cd $rb; ok cd $rb; ok
egrep foo\\|bar *.git/config | sort egrep foo\\|bar *.git/config
"; ";
cmp 'bar.git/config: bare = true $t = join("\n", sort (lines()));
bar.git/config: bar = one
cmp $t, 'bar.git/config: bar = one
bar.git/config: bare = true
bar.git/config:[foo] bar.git/config:[foo]
foo.git/config: bare = true
foo.git/config: bar = f1 foo.git/config: bar = f1
foo.git/config: bare = true
foo.git/config:[foo] foo.git/config:[foo]
frob.git/config: bar = dft frob.git/config: bar = dft
frob.git/config: bare = true frob.git/config: bare = true
@ -76,8 +80,7 @@ frob.git/config:[foo]
gitolite-admin.git/config: bare = true gitolite-admin.git/config: bare = true
testing.git/config: bar = dft testing.git/config: bar = dft
testing.git/config: bare = true testing.git/config: bare = true
testing.git/config:[foo] testing.git/config:[foo]';
';
try "cd $od; ok"; try "cd $od; ok";
@ -97,23 +100,23 @@ try "ADMIN_PUSH set1; !/FATAL/" or die text();
try " try "
cd $rb; ok cd $rb; ok
egrep foo\\|bar *.git/config | sort egrep foo\\|bar *.git/config
"; ";
$t = join("\n", sort (lines()));
cmp 'bar.git/config: bare = true cmp $t, 'bar.git/config: bar = one
bar.git/config: bar = one bar.git/config: bare = true
bar.git/config:[foo] bar.git/config:[foo]
foo.git/config: bare = true
foo.git/config: bar = f1 foo.git/config: bar = f1
foo.git/config: bare = true
foo.git/config:[foo] foo.git/config:[foo]
frob.git/config: bare = true
frob.git/config: bar = none frob.git/config: bar = none
frob.git/config: bare = true
frob.git/config:[foo] frob.git/config:[foo]
gitolite-admin.git/config: bare = true gitolite-admin.git/config: bare = true
testing.git/config: bar = dft testing.git/config: bar = dft
testing.git/config: bare = true testing.git/config: bare = true
testing.git/config:[foo] testing.git/config:[foo]';
';
try "cd $od; ok"; try "cd $od; ok";
@ -129,22 +132,22 @@ try "ADMIN_PUSH set1; !/FATAL/" or die text();
try " try "
cd $rb; ok cd $rb; ok
egrep foo\\|bar *.git/config | sort egrep foo\\|bar *.git/config
"; ";
$t = join("\n", sort (lines()));
cmp 'bar.git/config: bare = true cmp $t, 'bar.git/config: bare = true
bar.git/config:[foo] bar.git/config:[foo]
foo.git/config: bare = true
foo.git/config: bar = f1 foo.git/config: bar = f1
foo.git/config: bare = true
foo.git/config:[foo] foo.git/config:[foo]
frob.git/config: bare = true
frob.git/config: bar = none frob.git/config: bar = none
frob.git/config: bare = true
frob.git/config:[foo] frob.git/config:[foo]
gitolite-admin.git/config: bare = true gitolite-admin.git/config: bare = true
testing.git/config: bar = dft testing.git/config: bar = dft
testing.git/config: bare = true testing.git/config: bare = true
testing.git/config:[foo] testing.git/config:[foo]';
';
try "cd $od; ok"; try "cd $od; ok";
@ -170,21 +173,20 @@ try "
try " try "
cd $rb; ok cd $rb; ok
egrep foo\\|bar *.git/config | sort find . -name config | xargs egrep foo\\|bar
find . -name config | xargs egrep foo\\|bar | sort
"; ";
$t = join("\n", sort (lines()));
cmp './bar/u2/one.git/config: bare = true cmp $t, './bar/u2/one.git/config: bar = one
./bar/u2/one.git/config: bar = one ./bar/u2/one.git/config: bare = true
./bar/u2/one.git/config:[foo] ./bar/u2/one.git/config:[foo]
./foo.git/config: bare = true
./foo.git/config: bar = f1 ./foo.git/config: bar = f1
./foo.git/config: bare = true
./foo.git/config:[foo] ./foo.git/config:[foo]
./frob.git/config: bare = true
./frob.git/config: bar = f1 ./frob.git/config: bar = f1
./frob.git/config: bare = true
./frob.git/config:[foo] ./frob.git/config:[foo]
./gitolite-admin.git/config: bare = true ./gitolite-admin.git/config: bare = true
./testing.git/config: bar = dft ./testing.git/config: bar = dft
./testing.git/config: bare = true ./testing.git/config: bare = true
./testing.git/config:[foo] ./testing.git/config:[foo]';
';

View File

@ -90,20 +90,20 @@ try "
tc u4n1 u4n2 tc u4n1 u4n2
PUSH u4 next; ok PUSH u4 next; ok
/To .*/foo.git/ /To .*/foo.git/
/new branch\\] ca3787119b7e8b9914bc22c939cefc443bc308da -> br-\\d+/ /new branch\\] ca3787119b7e8b9914bc22c939cefc443bc308da -> refs/partial/br-\\d+/
/file:///foo-pc/ /file:///foo-pc/
/52c7716..ca37871 next -> next/ /52c7716..ca37871 next -> next/
tag u4/nexttag; glt push u4 --tags tag u4/nexttag; glt push u4 --tags
/To file:///foo-pc/ /To file:///foo-pc/
/\\[new tag\\] u4/nexttag -> u4/nexttag/ /\\[new tag\\] u4/nexttag -> u4/nexttag/
/\\[new branch\\] ca3787119b7e8b9914bc22c939cefc443bc308da -> br-\\d+/ /\\[new branch\\] ca3787119b7e8b9914bc22c939cefc443bc308da -> refs/partial/br-\\d+/
checkout master checkout master
checkout -b dev/u4/u4master checkout -b dev/u4/u4master
tc devu4m1 devu4m2 tc devu4m1 devu4m2
PUSH u4 HEAD; ok PUSH u4 HEAD; ok
/To .*/foo.git/ /To .*/foo.git/
/new branch\\] 228353950557ed1eb13679c1fce4d2b4718a2060 -> br-\\d+/ /new branch\\] 228353950557ed1eb13679c1fce4d2b4718a2060 -> refs/partial/br-\\d+/
/file:///foo-pc/ /file:///foo-pc/
/new branch.* HEAD -> dev/u4/u4master/ /new branch.* HEAD -> dev/u4/u4master/