1# readers add|rm: the owner and collaborators choose who reads a private2# repo; names must be users of this forge; a reader who is removed can't3# fetch any more.4. "$(dirname "$0")/../lib.sh"5user dami6user ana7user bob8user cat9repo --private dami/secret10clone dami dami/secret "$T/w/dami"11at "$T/w/dami" commit "first"12ok push_as dami "$T/w/dami" origin main1314fails fetch_ssh bob dami/secret15ok ssh_as dami readers dami/secret add bob16has "$T_LOG" 'bob can read dami/secret'17eq "$(cat "$FORGE_ROOT/dami/secret.git/forge/readers")" bob18ok fetch_ssh bob dami/secret19ok ssh_as dami readers dami/secret add bob20has "$T_LOG" 'bob already reads'21eq "$(grep -c . "$FORGE_ROOT/dami/secret.git/forge/readers")" 122fails_with "no user nobody" ssh_as dami readers dami/secret add nobody23fails_with "no user \\.\\./x" ssh_as dami readers dami/secret add ../x24fails_with "usage: readers" ssh_as dami readers dami/secret drop bob2526# A reader reads but doesn't choose readers; a collaborator does.27fails_with "only dami and collaborators of dami/secret" ssh_as bob readers dami/secret add cat28fails_with "only dami and collaborators of dami/secret" ssh_as bob private dami/secret29printf 'ana\n' >"$FORGE_ROOT/dami/secret.git/forge/collaborators"30ok ssh_as ana readers dami/secret add cat31ok ssh_as ana readers dami/secret32eq "$(output)" "bob33cat"3435ok ssh_as dami readers dami/secret rm bob36eq "$(cat "$FORGE_ROOT/dami/secret.git/forge/readers")" cat37fails fetch_ssh bob dami/secret38fails_with "bob is not a reader" ssh_as dami readers dami/secret rm bob39ok fetch_ssh cat dami/secret4041# On a public repo the list waits until it goes private.42repo dami/open43ok ssh_as dami readers dami/open add bob44has "$T_LOG" 'counts once it is private'