3 # Gitolite permission manipulation helper script
4 # Copyright 2011, Michal Sojka <wsh@2x.cz>
7 curr_branch=$(git symbolic-ref -q HEAD)
8 curr_branch_short="${curr_branch#refs/heads/}"
9 remote=$(git config --get branch.$curr_branch_short.remote)
10 url=$(git config --get remote.$remote.url) || url=$remote
12 url_sans_ssh=${url#ssh://}
13 if test x$url_sans_ssh != x$url; then
14 userhost=${url_sans_ssh%%/*}
15 repo=${url_sans_ssh#*/}
23 if test x$bn = xgl-perm; then
31 if test $# -gt 0; then echo >&2 "Command $cmd does not accept any arguments"; exit 1; fi
32 ssh $userhost getperms $repo;;
34 if test $# -gt 0; then echo >&2 "Command $cmd does not accept any arguments - it reads from stdin"; exit 1; fi
35 ssh $userhost setperms $repo;;
37 perms=$(ssh $userhost getperms $repo)
38 ( test "$perms" && echo "$perms"; echo $* ) | ssh $userhost setperms $repo;;
41 perms=$(ssh $userhost getperms $repo) # setperms does not work when executed in the same pipe with getperms
42 echo "$perms" | sed -e "s/[[:space:]]*\\b$user\\b//g" -e "/^[[:alnum:]]\+[[:space:]]*$/d" | ssh $userhost setperms $repo;;