]> oss.titaniummirror.com Git - deploy-utils.git/commitdiff
git-push-public: more flexible command line
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 27 Sep 2012 23:56:34 +0000 (17:56 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 27 Sep 2012 23:56:34 +0000 (17:56 -0600)
Select public server and/or specific repositories from the command line.
Also improve the display output a bit.

git-push-public

index 3799985d8d96894a54ee1cd46bd21d2e22d43af3..4b57b9783f355e317ae95184d6ba6e195c214d03 100755 (executable)
@@ -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