]> rtime.felk.cvut.cz Git - sojka/gl-perm.git/blob - gl-tool
Implement also description manipulation
[sojka/gl-perm.git] / gl-tool
1 #!/bin/sh
2
3 # Gitolite helper script for manipulating with permission and description manipulation
4 # Copyright 2011, 2014, 2017, Michal Sojka <wsh@2x.cz>
5 # License: GNU GPLv2+
6
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
11
12 url_sans_ssh=${url#ssh://}
13 if [ x"$url_sans_ssh" != x"$url" ]; then
14     userhost=${url_sans_ssh%%/*}
15     repo=${url_sans_ssh#*/}
16 else
17     # scp-like syntax
18     userhost=${url%%:*}
19     repo=${url#*:}
20 fi
21 repo=${repo%.git}
22
23 case "$(basename "$0")" in
24     gl-perm|gl-perm-list)
25         set -- perms "$repo" -l;;
26     gl-perm-add-writer)
27         set -- perms "$repo" + WRITERS "${1?Missing user name}";;
28     gl-perm-add-reader)
29         set -- perms "$repo" + READERS "${1?Missing user name}";;
30     gl-perm-rm-writer)
31         set -- perms "$repo" - WRITERS "${1?Missing user name}";;
32     gl-perm-rm-reader)
33         set -- perms "$repo" - READERS "${1?Missing user name}";;
34     gl-desc-get)
35         set -- desc "$repo";;
36     gl-desc-set)
37         set -- desc "$repo" "${1?No description given}";;
38 esac
39
40 (set -x; ssh "$userhost" "$@")