]> git.nbdom.net Git - nb.git/commitdiff
git_create
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Fri, 19 Aug 2016 10:56:20 +0000 (11:56 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Fri, 19 Aug 2016 10:56:20 +0000 (11:56 +0100)
etc/profile.d/git.sh

index bf517098352df0e42663ad60c677787add85c4eb..46ac6b2e2212a338ad385713904417991466e957 100644 (file)
@@ -74,11 +74,8 @@ GIT_REPO='git@git.nbdom.net'
 git_create() {
 # NB 14.04.16   shell_help_noarg "Usage: $FUNCNAME DIRECTORY" "$@" && return 1
 # NB 14.04.16   declare dir="$1"; shift
-  shell_help "Usage: $FUNCNAME DIRECTORY" "$@" && return 1
+  shell_help "Usage: $FUNCNAME create git project from current dir" "$@" && return 1
   declare dir="$(basename $(pwd))"
-# NB 21.08.15   declare name="${dir}.git"
-# NB 30.07.15   declare name="${1%.git}"
-# NB 30.07.15   declare dir=$(basename $name)
   declare repo="$GIT_REPO"
   [ -n "$1" ] && repo="$1" && shift
 
@@ -88,11 +85,8 @@ git_create() {
 # NB 14.04.16   [ -e "$dir" ] && echo ">$dir already exists!" 1>&2 && return 1
 
   echo ">git init --bare ${dir}.git"
-  ssh $repo "test -e ${dir}.git && echo "${dir}.git already exists on $repo" 1>&2 && exit 1; git init --bare ${dir}.git" || return
-
-  #echo ">git clone ${repo}:${dir}.git ."
-  #git clone ${repo}:${dir}.git . || return
-  #cd $dir || return
+  local user=${repo%@*}
+  ssh root@${repo#*@} "cd ~git || exit; test -e ${dir}.git && echo "${dir}.git already exists on $repo" 1>&2 && exit 1; git init --bare ${dir}.git && chown $user.$user ${dir}.git" || return
 
   echo ">git init"
   git init