]> git.nbdom.net Git - nb.git/commitdiff
git.sh
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 6 Sep 2016 14:09:44 +0000 (15:09 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 6 Sep 2016 14:09:44 +0000 (15:09 +0100)
etc/profile.d/git.sh

index 6dc9b47c5cc26cb43c7219db27586d89a7da2b29..bfe513958e7a2df96c013a290ba453fb895ec714 100644 (file)
@@ -77,7 +77,7 @@ git_create() {
   shell_help "Usage: $FUNCNAME create git project from current dir" "$@" && return 1
 
   declare dir="$(basename $(pwd))"
-  declare repo="$GIT_REPO"
+  declare repo=$(echo "$GIT_REPO" | perl -pe 's,^\w+://,,; s,/.*$,,;')
   [ -n "$1" ] && repo="$1" && shift
 
   #
@@ -108,9 +108,16 @@ git_create() {
 }
 
 git_clone() {
-  git clone $GIT_REPO:${1%.git}.git
+  declare repo=$GIT_REPO
+  case "$repo" in
+    *"//"*)  ;;
+    *) repo="$repo:"
+  esac
+
+  git clone ${repo}${1%.git}.git
 }
 
 git_list() {
-  ssh $GIT_REPO list | perl -ne '/(\S+).git/ and print "$1\n"'
+  local repo=$(echo "$GIT_REPO" | perl -pe 's,^\w+://,,; s,/.*$,,;')
+  ssh $repo list | perl -ne '/(\S+).git/ and print "$1\n"'
 }