summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-04-18 12:33:46 +0200
committerJonas Smedegaard <dr@jones.dk>2017-04-18 12:33:46 +0200
commit5d1a10c9f057f37ff7211843a834a3b91dc113bf (patch)
tree6b8c388d32ef49924a800acc0359fb36ad46ae14
parent94618d4acfe1544a994fe0e93d37bc6c34e486ce (diff)
Add public variable GIT_REPO. Document expansion of GIT_REPO into new internal variable BASEPATH.
-rwxr-xr-xlocalgit-remote-init-push17
1 files changed, 10 insertions, 7 deletions
diff --git a/localgit-remote-init-push b/localgit-remote-init-push
index 1f5717a..c1740ed 100755
--- a/localgit-remote-init-push
+++ b/localgit-remote-init-push
@@ -6,22 +6,23 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG PROJECT [GIT_HOST [SSH_CONN [GIT_REMOTE]]]
+Usage: $PRG PROJECT [GIT_REPO [SSH_CONN [GIT_REMOTE]]]
Initialize remote git, push local git, and set as default remote.
PROJECT basename or relative path for remote git project
- GIT_HOST hostname for public git access
+ GIT_REPO hostname for public git access
default: "source." + current domainname
SSH_CONN hostname for ssh, optionally with user + "@" prepended
- default: GIT_HOST
+ default: GIT_REPO
GIT_REMOTE name for local repository set
default: "origin"
-Full remote path becomes SSH_USER@SSH_HOST:/srv/git/GIT_HOST/PROJECT.git
+Full remote path becomes SSH_USER@SSH_HOST:BASEPATH/PROJECT.git
+where BASEPATH is resolved as "/srv/git/" + GIT_REPO
When local repository set is "origin" it is marked as default remote.
@@ -49,12 +50,14 @@ while true; do
done
PROJECT=${1-$(showhelp; exit1 "project name missing")}
-GIT_HOST=${2:-source.$(dnsdomainname --domain)}
+GIT_REPO=${2:-source.$(dnsdomainname --domain)}
+GIT_HOST=$GIT_REPO
+BASEPATH=/srv/git/"$GIT_REPO"
SSH_CONN=${3:-$GIT_HOST}
GIT_REMOTE=${4:-origin}
[ origin != "$GIT_ORIGIN" ] || ORIGIN_IS_DEFAULT=yes
-ssh "$SSH_CONN" git init --bare --shared /srv/git/"$GIT_HOST"/"$PROJECT".git
-git remote add "$GIT_REMOTE" "$SSH_CONN":/srv/git/"$GIT_HOST"/"$PROJECT".git
+ssh "$SSH_CONN" git init --bare --shared "$BASEPATH"/"$PROJECT".git
+git remote add "$GIT_REMOTE" "$SSH_CONN":"$BASEPATH"/"$PROJECT".git
git push ${ORIGIN_IS_DEFAULT:+--set-upstream "$GIT_REMOTE"} master