git-srv-admin.sh: Beautify code

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-01-04 18:04:17 +00:00
commit 53a75a70a7

View file

@ -15,7 +15,9 @@ usage()
| commands are: | commands are:
| |
| create-repo name | create-repo name
| update-descriptions
| list-repos | list-repos
| create-repo-dir
| list-maintainers | list-maintainers
| |
EOT EOT
@ -69,7 +71,7 @@ md_p()
md $@ md $@
} }
create_repo_dir() cmd_cmd_create_repo_dir()
{ {
if [ "$UID" != 0 ]; then if [ "$UID" != 0 ]; then
fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root" fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
@ -81,7 +83,7 @@ create_repo_dir()
md_p $dir 02750 $id `id -g $id` md_p $dir 02750 $id `id -g $id`
} }
create_repo() cmd_create_repo()
{ {
[ -e $dir ] && { [ -e $dir ] && {
err "$dir already exists" err "$dir already exists"
@ -101,12 +103,12 @@ read_project_metadata()
git -C $pd show HEAD:make/project.conf | sed -n "/^\[$field\]/,/^\[/ p" | grep -v '\[' | cat -s | sed '${/^$/d;}' git -C $pd show HEAD:make/project.conf | sed -n "/^\[$field\]/,/^\[/ p" | grep -v '\[' | cat -s | sed '${/^$/d;}'
} }
update_descriptions() cmd_update_descriptions()
{ {
[ -d $pdir ] || return 0 [ -d $pdir ] || return 0
cd $pdir || return 1 cd $pdir || return 1
local projs="$*" local projs="$*"
[ "$projs" = all ] && projs=`list_repos` [ "$projs" = all ] && projs=`cmd_list_repos`
local proj local proj
for proj in $projs; do for proj in $projs; do
umask 0022 umask 0022
@ -129,7 +131,7 @@ update_descriptions()
done done
} }
list_repos() cmd_list_repos()
{ {
[ -d $pdir ] || return 0 [ -d $pdir ] || return 0
cd $pdir || return 1 cd $pdir || return 1
@ -137,7 +139,7 @@ list_repos()
return $? return $?
} }
list_maintainers() cmd_list_maintainers()
{ {
local dev_chief=jan local dev_chief=jan
local master_dir=/srv/git/$dev_chief/proj local master_dir=/srv/git/$dev_chief/proj
@ -223,21 +225,21 @@ dir=$pdir/$p
case $cmd in case $cmd in
create-personal-project|create-repo) create-personal-project|create-repo)
check_user_is_self check_user_is_self
create_repo "$@" cmd_create_repo "$@"
;; ;;
update-descriptions|update-descr) update-descriptions|update-descr)
update_descriptions "$@" cmd_update_descriptions "$@"
;; ;;
list-personal-projects|list-repos) list-personal-projects|list-repos)
list_repos "$@" cmd_list_repos "$@"
;; ;;
create-project-dir|create-repo-dir) create-project-dir|create-repo-dir)
dir=$1 # this is all a horrible variable and usage mess dir=$1 # this is all a horrible variable and usage mess
check_user_is_self check_user_is_self
create_repo_dir "$@" cmd_cmd_create_repo_dir "$@"
;; ;;
list-maintainers|maintainers) list-maintainers|maintainers)
list_maintainers cmd_list_maintainers
;; ;;
*) *)
usage 1 usage 1