From afc03d0224f04b0bd57402408e608c6ef81b522d Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 21 Feb 2015 16:19:56 +0100 Subject: Add localmrsync and localvcshinit. --- localmrsync | 56 +++++++++++++++++++++++++++++++++++++++++++++ localvcshinit | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100755 localmrsync create mode 100755 localvcshinit 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 +# 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 . +# +# 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 diff --git a/localvcshinit b/localvcshinit new file mode 100755 index 0000000..9f9da81 --- /dev/null +++ b/localvcshinit @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright © 2014-2015 Jonas Smedegaard +# Description: initialize vcsh local + remote git repository +# +# 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 . +# +# Depends: vcsh git + +set -eu + +skel_url=https://github.com/RichiH/vcsh_mr_template + +PRG=$(basename "$0") + +showhelp() { + cat <&2 "$response" + exit 1 +} + +repo=${1:-mr} +base_url="$2" +url="$base_url/$repo" + +if [ $# -ne 2 ]; then + showhelp + exit1 "wrong parameters" +fi + +if ! vcsh list | grep -Fxq "$repo"; then + if [ vcsh = "$repo" ]; then + url="$base_url" + vcsh clone $skel_url mr + vcsh "$repo" remote set-url origin "$url" + else + vcsh init "$repo" + vcsh "$repo" remote add origin "$url" + fi +fi + +host=$(echo "$url" | sed -e 's/:.*//') +path=$(echo "$url" | sed -e 's/.*://') +if ssh "$host" test -d "$path.git"; then + echo "Skipping vcsh remote \"$repo\" already pushed" +else + ssh "$host" mkdir -p "$(dirname "$path")" + ssh "$host" git init --bare "$path.git" + vcsh "$repo" push --set-upstream origin master +fi + +printf 'Done (press return)' +read foo -- cgit v1.2.3