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!)
This commit is contained in:
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
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!**
WARNINGS:

View file

@ -20,13 +20,13 @@ exec >&2
main=`git config --file $GL_REPO_BASE/$repo.git/config --get gitolite.partialCopyOf`;
[ -z "$main" ] && exit 0
rand=$RANDOM
rand=$$
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
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"
exit 0

View file

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

View file

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

View file

@ -32,7 +32,7 @@ try "
glt clone u1 file://aa u1aa; ok; /Cloning into 'u1aa'.../
/warning: You appear to have cloned an empty repository/
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
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
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/u1e.git/gl-perms
';
try "cd $rb; find . -name gl-creator | sort | xargs md5sum"; cmp
'346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1a2.git/gl-creator
e4774cdda0793f86414e8b9140bb6db4 ./foo/u1/u1a.git/gl-creator
try "cd $rb; find . -name gl-creator"; $t = md5sum(sort (lines())); cmp $t,
'e4774cdda0793f86414e8b9140bb6db4 ./foo/u1/u1a.git/gl-creator
346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1a2.git/gl-creator
346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1e.git/gl-creator
';

View file

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

View file

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