clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / private-clone.sh
private-clone.sh 2.5K
1# A private repo over ssh: its owner, collaborators and readers clone and2# fetch it; anyone else gets exactly what a missing repo gives, byte for3# byte, however the path is spelled.4. "$(dirname "$0")/../lib.sh"5user dami6user ana7user bob8user cat9repo --private dami/secret10missing "$FORGE_ROOT/dami/secret.git/git-daemon-export-ok"11clone dami dami/secret "$T/w/dami"12at "$T/w/dami" commit "first"13ok push_as dami "$T/w/dami" origin main14mkdir "$FORGE_ROOT/dami/secret.git/forge"15printf 'ana\n' >"$FORGE_ROOT/dami/secret.git/forge/collaborators"16printf 'bob\n' >"$FORGE_ROOT/dami/secret.git/forge/readers"1718ok clone_ssh dami dami/secret "$T/w/dami2"19ok clone_ssh ana dami/secret "$T/w/ana"20ok clone_ssh bob dami/secret "$T/w/bob"21has "$T/w/bob/file1.txt" '^first'22fails clone_ssh cat dami/secret "$T/w/cat"23missing "$T/w/cat"2425# Every way of reaching the repo, as cat, against the same path with the26# repo gone. upload-archive (git archive --remote) and both command forms too.27ln -s ../dami/secret.git "$FORGE_ROOT/cat/link.git"28for cmd in "git-upload-pack 'dami/secret.git'" "git upload-pack 'dami/secret'" "git-upload-pack 'dami/secret.git/'" \29 "git-upload-pack 'dami/../dami/secret.git'" "git-upload-pack '$FORGE_ROOT/dami/secret.git'" \30 "git-upload-pack '~/dami/secret.git'" "git-upload-pack 'cat/link.git'" "git-upload-archive 'dami/secret.git'" \31 "git upload-pack 'dami/secret.git'" "git-upload-pack 'dami/'\\''secret.git'"; do32 fails ssh_as cat "$cmd" </dev/null33 denied=$(output)34 aside dami/secret35 fails ssh_as cat "$cmd" </dev/null36 back dami/secret37 eq "$denied" "$(output)"38done39has "$T_LOG" "'dami/'secret.git' does not appear to be a git repository"4041# What the client sees, ls-remote and archive.42fails fetch_ssh cat dami/secret43denied=$(output)44aside dami/secret45fails fetch_ssh cat dami/secret46back dami/secret47eq "$denied" "$(output)"48has "$T_LOG" "'dami/secret.git' does not appear to be a git repository"49ok fetch_ssh bob dami/secret50# The server's stderr and the client's lines race, so compare them sorted.51fails at "$T/w/bob" env FORGE_USER=cat git -c core.sshCommand="$T/ssh" archive --remote="$FORGE_SSH:dami/secret.git" main52denied=$(output | sort)53aside dami/secret54fails at "$T/w/bob" env FORGE_USER=cat git -c core.sshCommand="$T/ssh" archive --remote="$FORGE_SSH:dami/secret.git" main55back dami/secret56eq "$denied" "$(output | sort)"57ok at "$T/w/bob" env FORGE_USER=bob git -c core.sshCommand="$T/ssh" archive -o "$T/bob.tar" --remote="$FORGE_SSH:dami/secret.git" main5859# A public repo is still anyone's.60repo dami/open61ok fetch_ssh cat dami/open