From 93718df33fa2f620db2d0eee1d25d05554fb9995 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 14 Apr 2016 22:58:56 +0100 Subject: [PATCH] git_create from current dir --- etc/profile.d/git.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/etc/profile.d/git.sh b/etc/profile.d/git.sh index a6a18c23..b20b693b 100644 --- a/etc/profile.d/git.sh +++ b/etc/profile.d/git.sh @@ -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() { -- 2.47.3