diff --git a/contrib/adc/adc.common-functions b/contrib/adc/adc.common-functions new file mode 100644 index 0000000..c67710a --- /dev/null +++ b/contrib/adc/adc.common-functions @@ -0,0 +1,17 @@ +#!/bin/bash + +# please make sure this file is NOT chmod +x + +die() { echo "$@"; exit 1; } + +get_rights_and_owner() { + local ans + ans=$(perl -I$HOME/.gitolite/src -Mgitolite -e 'cli_repo_rights("'$1'")') + + # set shell variables as needed + owner=${ans#* } + rights=${ans% *} + [[ $rights =~ C ]] && perm_create=yes || perm_create= + [[ $rights =~ R ]] && perm_read=yes || perm_read= + [[ $rights =~ W ]] && perm_write=yes || perm_write= +} diff --git a/contrib/adc/fork b/contrib/adc/fork new file mode 100755 index 0000000..758675f --- /dev/null +++ b/contrib/adc/fork @@ -0,0 +1,22 @@ +#!/bin/bash + +from=$1 +to=$2 + +. $(dirname $0)/adc.common-functions + +# we cannot just say "cd $GL_REPO_BASE_ABS; git clone $from.git $to.git". That +# won't set up the hooks or the gl-creater file that gitolite needs. So we now +# have a new "git-init" command! + +get_rights_and_owner $from +[[ -z $perm_read ]] && die "no read permissions on $from" + +get_rights_and_owner $to +[[ -z $perm_create ]] && die "no create permissions on $to" + +# let gitolite create the repo first +SSH_ORIGINAL_COMMAND="git-init '$to'" $GL_BINDIR/gl-auth-command $GL_USER +# then copy the refs from $from +cd $GL_REPO_BASE_ABS/$to.git +git fetch $GL_REPO_BASE_ABS/$from.git refs/*:refs/* diff --git a/contrib/adc/restrict-admin b/contrib/adc/restrict-admin new file mode 100755 index 0000000..97ad0d1 --- /dev/null +++ b/contrib/adc/restrict-admin @@ -0,0 +1,11 @@ +#!/bin/bash + +. $(dirname $0)/adc.common-functions + +get_rights_and_owner gitolite-admin +[[ -z $perm_write ]] && die "just *what* are you trying to pull, young man?" + +# and here you let them do the dangerous stuff +echo "+rm -rf $GL_REPO_BASE_ABS" +sleep 2 +echo ...just kidding! diff --git a/contrib/adc/rmrepo b/contrib/adc/rmrepo new file mode 100755 index 0000000..fa2554f --- /dev/null +++ b/contrib/adc/rmrepo @@ -0,0 +1,11 @@ +#!/bin/bash + +. $(dirname $0)/adc.common-functions + +delete=$1 + +get_rights_and_owner $delete +[[ $owner == $GL_USER ]] || die "$delete is not yours to delete!" + +cd $GL_REPO_BASE_ABS +rm -rf $delete.git