gitolite/t/t04a-wild-students
Sitaram Chamarty 6539009cb5 make REPO_BASE absolute early
$ENV{GL_REPO_BASE_ABS} is meant to point to the same directory as
$REPO_BASE, except it is meant to be passed to hooks, ADCs and other
child programs.  And since you can't be sure where the child program
starts in, this became an absolute path.

Gradually, however, I started using it wherever I needed an absolute
path (mostly in code that jumps around various directories to do stuff).
Which is silly, because there's no reason $REPO_BASE cannot also be made
an absolute, even if the rc file has a relative path.

So that's what I did now: made $REPO_BASE absolute very early on, and
then systematically changed all uses of the longer form to the shorter
form when appropriate.  And so the only thing we now use the longer one
for is to pass to child programs.

(Implementation note: The actual change is not very big, but while I was
about it I decided to make the test suite able to test with an absolute
REPO_BASE also, which is why the commit seems so large.)

----

This all started with a complaint from Damien Regad.  He had an
extremely odd setup where his bashrc changed PWD to something other than
$HOME before anything else ran.  This caused those two variables to
beceom inconsistent, and he had a 1-line fix he wanted me to apply.

I generally don't like making special fixes for for non-standard setups,
and anyway all he had to do was set the full path to REPO_BASE in the rc
file to get around this.  Which is what I told him and he very politely
left it at that.

However, this did get me thinking, and I soon realised I was needlessly
conflating "relative versus absolute" with "able to be passed to child
programs".  Fixing that solved his problem also, as a side-effect.

So I guess this is all thanks to Damien!
2011-03-21 07:51:10 +05:30

144 lines
3.4 KiB
Plaintext

# vim: syn=sh:
# ----------
name "INTERNAL"
echo "
@prof = u1
@TAs = u2 u3
@students = u4 u5 u6
@gfoo = foo/CREATOR/a[0-9][0-9]
repo @gfoo
C = @students
RW+ = CREATOR
RW = WRITERS @TAs
R = READERS @prof
" | ugc
notexpect ABORT
# reasonably complex setup; we'll do everything from one repo though
cd ~/td
name "u1 create fail"
runlocal git clone u1:foo/u1/a01
expect "R access for foo/u1/a01 DENIED to u1"
name "u2 create fail"
runlocal git clone u2:foo/u2/a02
expect "R access for foo/u2/a02 DENIED to u2"
name "u4 tries to create u2 repo"
runlocal git clone u4:foo/u2/a12
expect "R access for foo/u2/a12 DENIED to u4"
name "line anchored regexes"
runlocal git clone u4:foo/u4/a1234
expect "R access for foo/u4/a1234 DENIED to u4"
name "u4 tries to create his own repo"
runlocal git clone u4:foo/u4/a12
expect "Initialized empty Git repository in $TEST_BASE_FULL/foo/u4/a12.git/"
expect "warning: You appear to have cloned an empty repository."
name "u4 push success"
cd ~/td/a12
mdc;mdc;mdc;mdc
runlocal git push origin master
expect "To u4:foo/u4/a12"
expect "\* \[new branch\] master -> master"
name "u1 clone success"
cd ~/td
runlocal git clone u1:foo/u4/a12 u1a12
expect "Cloning into u1a12..."
name "u1 push fail"
cd ~/td/u1a12
mdc; mdc
runlocal git push
expect "W access for foo/u4/a12 DENIED to u1"
name "u2 clone success"
cd ~/td
runlocal git clone u2:foo/u4/a12 u2a12
expect "Cloning into u2a12..."
name "u2 push success"
cd ~/td/u2a12
mdc; mdc
runlocal git push
expect "To u2:foo/u4/a12"
expect "master -> master"
name "u2 rewind fail"
runlocal git push -f origin master^:master
expect "remote: + refs/heads/master foo/u4/a12 u2 DENIED by fallthru"
expect "remote: error: hook declined to update refs/heads/master"
expect "To u2:foo/u4/a12"
expect "\[remote rejected\] master^ -> master (hook declined)"
expect "error: failed to push some refs to 'u2:foo/u4/a12'"
name INTERNAL
# u4 pull to sync up
cd ~/td/a12
runlocal git pull
expect "Fast-forward"
expect "From u4:foo/u4/a12"
expect "master -> origin/master"
name "u4 rewind success"
runlocal git reset --hard HEAD^
runlocal git push -f
expect "To u4:foo/u4/a12"
expect "+ .* master -> master (forced update)"
name "u5 clone fail"
cd ~/td
runlocal git clone u5:foo/u4/a12 u5a12
expect "R access for foo/u4/a12 DENIED to u5"
name "setperm"
echo "
R u5
RW u6
" | runlocal ssh u4 setperms foo/u4/a12
expect_filesame $TESTDIR/out/t04-wild1.1
name "getperms"
runlocal ssh u4 getperms foo/u4/a12
expect_filesame $TESTDIR/out/t04-wild1.2
name "u5 clone success"
cd ~/td
runlocal git clone u5:foo/u4/a12 u5a12
expect "Cloning into u5a12..."
name "u5 push fail"
cd ~/td/u5a12
mdc; mdc
runlocal git push
expect "W access for foo/u4/a12 DENIED to u5"
name "u6 clone success"
cd ~/td
runlocal git clone u6:foo/u4/a12 u6a12
expect "Cloning into u6a12..."
name "u6 push success"
cd ~/td/u6a12
mdc; mdc
runlocal git push u6:foo/u4/a12
expect "To u6:foo/u4/a12"
expect "master -> master"
name "u6 rewind fail"
runlocal git push -f u6:foo/u4/a12 master^:master
expect "remote: + refs/heads/master foo/u4/a12 u6 DENIED by fallthru"
expect "remote: error: hook declined to update refs/heads/master"
expect "To u6:foo/u4/a12"
expect "\[remote rejected\] master^ -> master (hook declined)"
expect "error: failed to push some refs to 'u6:foo/u4/a12'"
name "INTERNAL"