summaryrefslogtreecommitdiff
path: root/localmrsync
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2015-02-21 16:19:56 +0100
committerJonas Smedegaard <dr@jones.dk>2015-02-21 16:19:56 +0100
commitafc03d0224f04b0bd57402408e608c6ef81b522d (patch)
treebd28b13b081a1f117a78a8876f9f44b4320b96d5 /localmrsync
parenta95890790e41ec1d96c1d56eacb71c6dd97856e8 (diff)
Add localmrsync and localvcshinit.
Diffstat (limited to 'localmrsync')
-rwxr-xr-xlocalmrsync56
1 files changed, 56 insertions, 0 deletions
diff --git a/localmrsync b/localmrsync
new file mode 100755
index 0000000..b34e7ca
--- /dev/null
+++ b/localmrsync
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Copyright © 2014-2015 Jonas Smedegaard <dr@jones.dk>
+# Description: create/update local + remote git and register in mr
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Depends: git mr
+
+set -eu
+
+for dir in "$@"; do
+ if [ ! -d "$dir" ]; then
+ echo "Skipping non-dir \"$dir\""
+ continue
+ fi
+ cd "$dir"
+ if [ ! -d .git ]; then
+ if [ -z "$GIT_INIT_BASEURL" ]; then
+ echo "Skipping non-git dir \"$dir\" (set GIT_INIT_BASEURL to initialize)"
+ cd ..
+ continue
+ fi
+ touch ../.mrconfig
+ git init
+ git add -A
+ git commit -m "Initial commit."
+ fi
+ if ! url=$(git config --get remote.origin.url); then
+ git remote add origin "$GIT_INIT_BASEURL"/"$dir"
+ url=$(git config --get remote.origin.url)
+ mr reg
+ fi
+ host=$(echo "$url" | sed -e 's/:.*//')
+ path=$(echo "$url" | sed -e 's/.*://')
+ if ! ssh "$host" test -d "$path.git"; then
+ ssh "$host" mkdir -p "$(dirname "$path")"
+ ssh "$host" git init --bare "$path.git"
+ fi
+ git add -A && git commit -m "Sync." || true
+ git push --set-upstream origin master || true
+ cd ..
+done
+
+printf 'Done (press return)'
+read foo