3 # Gitolite permission manipulation helper script
4 # Copyright 2011, 2014, 2017, Michal Sojka <wsh@2x.cz>
10 Usage: $0 Print current permissions
11 $0 + READERS <user> Allow <user> to read the repo (@all for all users)
12 $0 - READERS <user> Remove <user> from the list of readers
13 $0 + WRITERS <user> Allow <user> to write the repo
18 curr_branch=$(git symbolic-ref -q HEAD)
19 curr_branch_short=${curr_branch#refs/heads/}
20 remote=$(git config --get "branch.$curr_branch_short.remote")
21 url=$(git config --get "remote.$remote.url") || url=$remote
23 url_sans_ssh=${url#ssh://}
24 if [ x"$url_sans_ssh" != x"$url" ]; then
25 userhost=${url_sans_ssh%%/*}
26 repo=${url_sans_ssh#*/}
34 case "$(basename "$0")" in
38 set -- "$repo" + WRITERS "${1?Missing user name}";;
40 set -- "$repo" + READERS "${1?Missing user name}";;
42 set -- "$repo" - WRITERS "${1?Missing user name}";;
44 set -- "$repo" - READERS "${1?Missing user name}";;
47 (set -x; ssh "$userhost" perms "$@")