From 1a944709215925ec369ae56e64559e8be3f679fd Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Thu, 27 Sep 2012 17:56:34 -0600 Subject: [PATCH] git-push-public: more flexible command line Select public server and/or specific repositories from the command line. Also improve the display output a bit. --- git-push-public | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/git-push-public b/git-push-public index 3799985..4b57b97 100755 --- a/git-push-public +++ b/git-push-public @@ -6,23 +6,49 @@ LOCALBASE=/var/lib/git PUBLICBASE=/var/cache/git -PUBLICSERVER="$1" -[ -z "$PUBLICSERVER" ] && PUBLICSERVER=oss.titaniummirror.com +PUBLICSERVER=oss.titaniummirror.com + +push_repo() +{ + local repo=$1 -echo "Updating git repos on server $PUBLICSERVER" -cd $LOCALBASE -for path in $(find . -name git-daemon-export-ok); do - repo="${path/\/git-daemon-export-ok/}" - repo="${repo/.\//}" - echo "Repository $repo" if ! ssh $PUBLICSERVER test -d $PUBLICBASE/$repo ; then # Repo does not exist on public server, so create it - echo "Creating repository $repo on remote" + echo "-- creating $repo" ssh $PUBLICSERVER git --git-dir=$PUBLICBASE/$repo init --bare ssh $PUBLICSERVER touch $PUBLICBASE/$repo/git-daemon-export-ok scp $repo/description $PUBLICSERVER:$PUBLICBASE/$repo/ ssh $PUBLICSERVER "echo \"git://$PUBLICSERVER/$repo\" \ > $PUBLICBASE/$repo/cloneurl" fi + echo "-- syncing $repo" git --git-dir=$repo push --mirror $PUBLICSERVER:$PUBLICBASE/$repo -done +} + +## MAIN ## + +if [ "$1" = "-s" -a -n "$2" ]; then + PUBLICSERVER="$2" + shift; shift +fi +repos="$*" + +echo "-- server $PUBLICSERVER" +cd $LOCALBASE +if [ -n "$repos" ]; then + for repo in $repos; do + if [ -f "$repo/git-daemon-export-ok" ]; then + repo="${repo/\/git-daemon-export-ok/}" + repo="${repo/.\//}" + push_repo $repo + else + echo "-- skipping private repo $repo" + fi + done +else + for path in $(find . -name git-daemon-export-ok); do + repo="${path/\/git-daemon-export-ok/}" + repo="${repo/.\//}" + push_repo $repo + done +fi -- 2.39.2