[asterisk-scf-commits] asterisk-scf/integration/gitall.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Oct 27 10:50:56 CDT 2010


branch "master" has been updated
       via  859bcd431f380a66718e9fc35f962cca72a06647 (commit)
      from  399d724ee91372455d99f3ff9e81da7891f47999 (commit)

Summary of changes:
 gitall-asterisk-scf.sh |   66 ++++++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 32 deletions(-)


- Log -----------------------------------------------------------------
commit 859bcd431f380a66718e9fc35f962cca72a06647
Author: David M. Lee <dlee at digium.com>
Date:   Wed Oct 27 10:49:06 2010 -0500

    Adding more git commands to the gitall script.

diff --git a/gitall-asterisk-scf.sh b/gitall-asterisk-scf.sh
index 87d2250..939e52e 100755
--- a/gitall-asterisk-scf.sh
+++ b/gitall-asterisk-scf.sh
@@ -5,20 +5,21 @@ exe=$(basename $0)
 function usage()
 {
     cat <<EOF
-usage: ${exe} [-ssh-key key-file] [pull | push | tag]
+usage: ${exe} [-ssh-key key-file] [GIT_COMMAND] [GIT_COMMAND_OPTIONS]
 
 This script will startup ssh-agent (if necessary) and run a series of git
 commands on all of the repos managed by gitall.
 
 Options:
-   --ssh-key Specify the key-file to use for git.  Usually fine without it.
+   --ssh-key   Specify the key-file to use for git. Usually fine without it.
 
 Commands:
-   pull pull/clone all managed repos.  Takes no options
-   tag  runs the git tag command on all managed repos.  See man git-tag for
-        options.
-   push runs the git push command on all managed repos.  See man git-push for
-        options.  Recommend *serious* paranoia when running this command.
+   pull, push, tag, status, branch, diff, submodule
+
+   Pull will detect missing repos and clone as necessary.
+   Other than pull, all commands accept normal git options.
+   Push tries to be safe by running --dry-run prior to the actual push.
+     Still recommend *serious* paranoia when running this command.
 
 If no command is given, pull is run by default.
 EOF
@@ -47,17 +48,17 @@ cmd=pull
 
 while test $# -gt 0; do
     case $1 in
-        pull)
-            cmd=pull
-            shift 1
-            ;;
-        tag)
-            cmd=tag
-            shift 1
+        tag|status|branch|diff|submodule)
+            cmd=passthrough
+            break
             ;;
         push)
-            cmd=push
-            shift 1
+            cmd=dry_run
+            break
+            ;;
+        pull)
+            cmd=pull
+            break
             ;;
         --ssh-key)
             export ssh_key=$2
@@ -68,13 +69,17 @@ while test $# -gt 0; do
             exit 0
             ;;
         *)
-            break
+            usage >&2
+            exit 1
             ;;
     esac
 done
 
 function pull()
 {
+    # don't need the pull argument
+    shift 1
+
     # between cloning if child repo's aren't there, and exec'ing out to
     # git pull for this repo, passing along params is a bit difficult
     if test $# -gt 0; then
@@ -136,7 +141,7 @@ EOF
     fi
 } # pull
 
-function tag()
+function passthrough()
 {
     for repo in . "${repos[@]}"; do
         repoDir=$(basename ${repo})
@@ -146,19 +151,20 @@ function tag()
             echo "!! Repo ${repoName} not yet cloned" >&2
             exit 1
         fi
-        echo ">> git tag" "$@" "(${repoName})"
-        ( cd ${repoDir} && git tag "$@" )
+        echo ">> git" "$@" "(${repoName})"
+        ( cd ${repoDir} && git "$@" )
         if test $? -ne 0; then
             echo >&2
             echo "!! Failed to tag ${repoName}." >&2
             exit 1
         fi
+        echo
     done
-} # tag
+} # passthrough
 
-function push()
+function dry_run()
 {
-    echo ">> git push" "$@" "(dry-run)"
+    echo ">> git" "$@" "(dry-run)"
     for repo in . "${repos[@]}"; do
         repoDir=$(basename ${repo})
         repoName=$(basename $(cd ${repoDir} && pwd))
@@ -166,10 +172,10 @@ function push()
             echo "!! Repo ${repoName} not yet cloned" >&2
             exit 1
         fi
-        ( cd ${repoDir} && git push "$@" --dry-run --quiet )
+        ( cd ${repoDir} && git "$@" --dry-run --quiet )
         if test $? -ne 0; then
             echo >&2
-            echo "!! Would fail to push ${repoName}." >&2
+            echo "!! Would fail to $1 ${repoName}." >&2
             exit 1
         fi
     done
@@ -178,19 +184,15 @@ function push()
     for repo in . "${repos[@]}"; do
         repoDir=$(basename ${repo})
         repoName=$(basename $(cd ${repoDir} && pwd))
-        if ! test -d ${repoDir}/.git; then
-            echo "!! Repo ${repoName} not yet cloned" >&2
-            exit 1
-        fi
-        echo ">> git push" "$@" "(${repoName})"
-        ( cd ${repoDir} && git push "$@" )
+        echo ">> git" "$@" "(${repoName})"
+        ( cd ${repoDir} && git "$@" )
         if test $? -ne 0; then
             echo "!! Failed to push ${repoName}." >&2
             exit 1
         fi
         echo
     done
-} # push
+} # dry_run
 
 #
 # Main script

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/gitall.git



More information about the asterisk-scf-commits mailing list