mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
git-srv-admin.sh: Some code and usage cleanup
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
aea176c7b3
commit
ec115ab6ff
1 changed files with 30 additions and 19 deletions
|
|
@ -10,12 +10,12 @@ usage()
|
|||
|
|
||||
| global options are:
|
||||
|
|
||||
| -j : project is a jannet-project (default is a private project)
|
||||
| -F flavour : flavour is one of: priv, jw, contrib
|
||||
|
|
||||
| commands are:
|
||||
|
|
||||
| create-personal-project name
|
||||
| list-personal-projects
|
||||
| create-repo name
|
||||
| list-repos
|
||||
|
|
||||
EOT
|
||||
[ "$1" ] && exit $1
|
||||
|
|
@ -68,7 +68,7 @@ md_p()
|
|||
md $@
|
||||
}
|
||||
|
||||
create_project_dir()
|
||||
create_repo_dir()
|
||||
{
|
||||
if [ "$UID" != 0 ]; then
|
||||
fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
|
||||
|
|
@ -80,7 +80,7 @@ create_project_dir()
|
|||
md_p $dir 02750 $id `id -g $id`
|
||||
}
|
||||
|
||||
create_personal_project()
|
||||
create_repo()
|
||||
{
|
||||
[ -e $dir ] && {
|
||||
err "$dir already exists"
|
||||
|
|
@ -93,7 +93,7 @@ create_personal_project()
|
|||
git init --bare --shared=0640 || fatal "git init failed"
|
||||
}
|
||||
|
||||
list_personal_projects()
|
||||
list_repos()
|
||||
{
|
||||
cd $pdir || return 1
|
||||
ls */HEAD | sed 's%/HEAD%%' 2>/dev/null
|
||||
|
|
@ -102,21 +102,22 @@ list_personal_projects()
|
|||
|
||||
# ----------------- here we go
|
||||
no_error_if_exists=0
|
||||
jannet_project=0
|
||||
id=`whoami`
|
||||
#user=$id
|
||||
flavour=priv
|
||||
|
||||
OPTIND=1
|
||||
while getopts jhu: flag; do
|
||||
while getopts jhu:F: flag; do
|
||||
|
||||
case $flag in
|
||||
h)
|
||||
usage 0;;
|
||||
u)
|
||||
user=$OPTARG
|
||||
;;
|
||||
j)
|
||||
jannet_project=1;;
|
||||
user=$OPTARG;;
|
||||
j) # legacy support
|
||||
flavour=jw;;
|
||||
F)
|
||||
flavour=$OPTARG;;
|
||||
p)
|
||||
no_error_if_exist=1;;
|
||||
*)
|
||||
|
|
@ -138,7 +139,17 @@ fi
|
|||
|
||||
git_home=/srv/git/$id
|
||||
pdir=$git_home/priv
|
||||
[ "$jannet_project" = 1 ] && pdir=$git_home/proj
|
||||
|
||||
case $flavour in
|
||||
jw)
|
||||
pdir=$git_home/proj;;
|
||||
priv)
|
||||
pdir=$git_home/priv;;
|
||||
contrib)
|
||||
pdir=$git_home/contrib;;
|
||||
*)
|
||||
fatal "unknown repository flavour \"$flavour\""
|
||||
esac
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
|
|
@ -147,17 +158,17 @@ p=$1
|
|||
dir=$pdir/$p
|
||||
|
||||
case $cmd in
|
||||
create-personal-project)
|
||||
create-personal-project|create-repo)
|
||||
check_user_is_self
|
||||
create_personal_project "$@"
|
||||
create_repo "$@"
|
||||
;;
|
||||
list-personal-projects)
|
||||
list_personal_projects "$@"
|
||||
list-personal-projects|list-repos)
|
||||
list_repos "$@"
|
||||
;;
|
||||
create-project-dir)
|
||||
create-project-dir|create-repo-dir)
|
||||
dir=$1 # this is all a horrible variable and usage mess
|
||||
check_user_is_self
|
||||
create_project_dir "$@"
|
||||
create_repo_dir "$@"
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue