]> git.nbdom.net Git - nb.git/commitdiff
git_create from current dir
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 14 Apr 2016 21:58:56 +0000 (22:58 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 14 Apr 2016 21:58:56 +0000 (22:58 +0100)
etc/profile.d/git.sh

index a6a18c23e736c05b581827d10a9e9e479c2d80de..b20b693b47e402a683ef81eb3ad848da8e45a44c 100644 (file)
@@ -36,45 +36,47 @@ git_commit_push_add() {
   git add . && git_commit_push "$*"
 }
 
-GIT_CREATE_REPO='git@git.nbdom.net'
+GIT_REPO='git@git.nbdom.net'
 git_create() {
-  shell_help_noarg "Usage: $FUNCNAME DIRECTORY" "$@" && return 1
-  declare dir="$1"; shift
+# 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
+  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_CREATE_REPO"
+  declare repo="$GIT_REPO"
   [ -n "$1" ] && repo="$1" && shift
 
   #
   # Check, create repo on server
   #
-  [ -e "$dir" ] && echo ">$dir already exists!" 1>&2 && return 1
+# NB 14.04.16   [ -e "$dir" ] && echo ">$dir already exists!" 1>&2 && return 1
 
   echo ">git init --bare ${dir}.git"
-  ssh $repo "git init --bare ${dir}.git" || return
+  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
+  echo ">git clone ${repo}:${dir}.git ."
+  git clone ${repo}:${dir}.git . || return
+  #cd $dir || return
 
-  echo ">git init [$dir]"
-  cd $dir || return
+  echo ">git init"
   git init
 
   # Create files
-  printf "$dir\n=============\n## Synopsis\n\nDESCRIPTION\n" > README.md
+  printf "\n=============\n## Synopsis\n\nDESCRIPTION\n" > README.md
 
-  echo ">git add ."
+  echo ">git add README.md"
   git add .
 
   echo ">git commit -m \"Created by $FUNCNAME\""
   git commit -m "Created by $FUNCNAME"
 
-  echo ">git push --set-upstream origin master"
-  git push --set-upstream origin master
-
   echo ">git remote add origin $repo:${dir}.git"
   git remote add origin $repo:${dir}.git
+
+  echo ">git push --set-upstream origin master"
+  git push --set-upstream origin master
 }
 
 git_clone() {