[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
Tue Oct 26 14:48:03 CDT 2010


branch "master" has been updated
       via  399d724ee91372455d99f3ff9e81da7891f47999 (commit)
       via  fc5848105cc4839bb028653614808617820ccc87 (commit)
      from  1a7d363a20b00b1dbc2b834c775f53953652f9cc (commit)

Summary of changes:
 gitall-asterisk-scf.sh |  243 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 180 insertions(+), 63 deletions(-)


- Log -----------------------------------------------------------------
commit 399d724ee91372455d99f3ff9e81da7891f47999
Author: David M. Lee <dlee at digium.com>
Date:   Tue Oct 26 14:36:33 2010 -0500

    Made the gitall script more like a git wrapper.  Now has tag and push options.

diff --git a/gitall-asterisk-scf.sh b/gitall-asterisk-scf.sh
index a07acfb..87d2250 100755
--- a/gitall-asterisk-scf.sh
+++ b/gitall-asterisk-scf.sh
@@ -1,49 +1,28 @@
 #!/bin/bash
 
-#Usage:
-#
-# getAsterskScf.sh
-#
+exe=$(basename $0)
 
-#if($# < 2); then
-#  echo "usage: bash getAsteriskScf.sh "
-#  exit 1
-#fi
+function usage()
+{
+    cat <<EOF
+usage: ${exe} [-ssh-key key-file] [pull | push | tag]
 
-# if we don't already have an ssh-agent running, fire one up
-if test ${SSH_AUTH_SOCK-no} = no; then
-    eval `ssh-agent`
+This script will startup ssh-agent (if necessary) and run a series of git
+commands on all of the repos managed by gitall.
 
-    echo "SSH_AGENT_PID = ${SSH_AGENT_PID}"
-    exec `ssh-add ${1}`
-    export kill_agent=yes
-fi
+Options:
+   --ssh-key Specify the key-file to use for git.  Usually fine without it.
 
-# check to see if gitall needs a pull
-echo ">> Fetching gitall"
-git fetch --all
-echo
-
-# if there is an upstream branch, and it has changes we don't
-if git rev-parse --verify @{upstream} > /dev/null 2>&1 &&
-    ! test -z "$(git log ^HEAD @{upstream})"; then
-    # We can't just git pull, because that would modify the running script,
-    # which tends to upset bash.  So we'll exec out to the git pull, and try
-    # this script again.
-    #
-    # DONT_PULL_GITALL is a recursion guard, in case of git weirdness.
-    if test ${DONT_PULL_GITALL-no} = no; then
-        echo ">> Updating gitall"
-        exec bash -c "git pull && DONT_PULL_GITALL=yes $0"
-    else
-        cat <<EOF >&2
+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.
 
-Cowardly refusing to pull gitall repo and re-run $0.
-Run git pull and try again.
+If no command is given, pull is run by default.
 EOF
-        exit 1
-    fi
-fi
+}
 
 gitdepot=git at git.asterisk.org
 
@@ -63,33 +42,171 @@ repos[i++]=integration/ice-util-c++
 repos[i++]=integration/test_channel
 repos[i++]=release/cmake
 
-for repo in "${repos[@]}"; do
-    repoDir=$(basename ${repo})
-    repoUri=${gitdepot}:${tree}/${repo}
+# by default, pull
+cmd=pull
+
+while test $# -gt 0; do
+    case $1 in
+        pull)
+            cmd=pull
+            shift 1
+            ;;
+        tag)
+            cmd=tag
+            shift 1
+            ;;
+        push)
+            cmd=push
+            shift 1
+            ;;
+        --ssh-key)
+            export ssh_key=$2
+            shift 2
+            ;;
+        --help|help)
+            usage
+            exit 0
+            ;;
+        *)
+            break
+            ;;
+    esac
+done
+
+function pull()
+{
+    # 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
+        echo "error: ${exe} pull take no params" >&2
+        exit 1
+    fi
+
+    # check to see if gitall needs a pull
+    echo ">> Fetching gitall"
+    git fetch --all
+    echo
 
-    if [ -d ${repoDir}/.git ]; then
-        if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
-            echo ">> Updating from repo ${repoUri}"
-            ( cd ${repoDir} && git pull )
+    # if there is an upstream branch, and it has changes we don't
+    if git rev-parse --verify @{upstream} > /dev/null 2>&1 &&
+        ! test -z "$(git log ^HEAD @{upstream})"; then
+        # We can't just git pull, because that would modify the running script,
+        # which tends to upset bash.  So we'll exec out to the git pull, and try
+        # this script again.
+        #
+        # DONT_PULL_GITALL is a recursion guard, in case of git weirdness.
+        if test ${DONT_PULL_GITALL-no} = no; then
+            echo ">> Updating gitall"
+            exec bash -c "git pull && DONT_PULL_GITALL=yes $0"
         else
-            echo "-- Skipping ${repoDir}; no upstream branch"
+            cat <<EOF >&2
+
+Cowardly refusing to pull gitall repo and re-run $0.
+Run git pull and try again.
+EOF
+            exit 1
         fi
-    else
-        echo ">> Cloning from ${repoUri} to ${repoDir}"
-        git clone ${repoUri} ${repoDir}
     fi
-    echo " "
-done
 
-if [ ! -d pjproject ]; then
-    echo " "
-    echo "--------- "
-    echo "REMINDER: You must manually install pjproject in this directory."
-    echo "  http://www.pjsip.org/download.htm"
-    echo "--------- "
-    echo " "
+    for repo in "${repos[@]}"; do
+        repoDir=$(basename ${repo})
+        repoUri=${gitdepot}:${tree}/${repo}
+
+        if [ -d ${repoDir}/.git ]; then
+            if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
+                echo ">> Pulling from repo ${repoUri}"
+                ( cd ${repoDir} && git pull )
+            else
+                echo "-- Skipping ${repoDir}; no upstream branch"
+            fi
+        else
+            echo ">> Cloning from ${repoUri} to ${repoDir}"
+            git clone ${repoUri} ${repoDir}
+        fi
+        echo " "
+    done
+
+    if [ ! -d pjproject ]; then
+        echo " "
+        echo "--------- "
+        echo "REMINDER: You must manually install pjproject in this directory."
+        echo "  http://www.pjsip.org/download.htm"
+        echo "--------- "
+        echo " "
+    fi
+} # pull
+
+function tag()
+{
+    for repo in . "${repos[@]}"; do
+        repoDir=$(basename ${repo})
+        repoName=$(basename $(cd ${repoDir} && pwd))
+        if ! test -d ${repoDir}/.git; then
+            echo >&2
+            echo "!! Repo ${repoName} not yet cloned" >&2
+            exit 1
+        fi
+        echo ">> git tag" "$@" "(${repoName})"
+        ( cd ${repoDir} && git tag "$@" )
+        if test $? -ne 0; then
+            echo >&2
+            echo "!! Failed to tag ${repoName}." >&2
+            exit 1
+        fi
+    done
+} # tag
+
+function push()
+{
+    echo ">> git push" "$@" "(dry-run)"
+    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
+        ( cd ${repoDir} && git push "$@" --dry-run --quiet )
+        if test $? -ne 0; then
+            echo >&2
+            echo "!! Would fail to push ${repoName}." >&2
+            exit 1
+        fi
+    done
+    echo
+
+    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 "$@" )
+        if test $? -ne 0; then
+            echo "!! Failed to push ${repoName}." >&2
+            exit 1
+        fi
+        echo
+    done
+} # push
+
+#
+# Main script
+#
+
+# if we don't already have an ssh-agent running, fire one up
+if test ${SSH_AUTH_SOCK-no} = no; then
+    eval `ssh-agent`
+
+    echo "SSH_AGENT_PID = ${SSH_AGENT_PID}"
+    exec `ssh-add ${1}`
+    export kill_agent=yes
 fi
 
+$cmd "$@"
+
 if test ${kill_agent-no} != no; then
     echo "killing ssh-agent"
     kill $SSH_AGENT_PID

commit fc5848105cc4839bb028653614808617820ccc87
Author: David M. Lee <dlee at digium.com>
Date:   Tue Oct 26 10:14:31 2010 -0500

    indent gitall-asterisk-scf.sh

diff --git a/gitall-asterisk-scf.sh b/gitall-asterisk-scf.sh
index f99e72a..a07acfb 100755
--- a/gitall-asterisk-scf.sh
+++ b/gitall-asterisk-scf.sh
@@ -12,11 +12,11 @@
 
 # if we don't already have an ssh-agent running, fire one up
 if test ${SSH_AUTH_SOCK-no} = no; then
-   eval `ssh-agent`
+    eval `ssh-agent`
 
-   echo "SSH_AGENT_PID = ${SSH_AGENT_PID}"
-   exec `ssh-add ${1}`
-   export kill_agent=yes
+    echo "SSH_AGENT_PID = ${SSH_AGENT_PID}"
+    exec `ssh-add ${1}`
+    export kill_agent=yes
 fi
 
 # check to see if gitall needs a pull
@@ -26,23 +26,23 @@ echo
 
 # if there is an upstream branch, and it has changes we don't
 if git rev-parse --verify @{upstream} > /dev/null 2>&1 &&
-   ! test -z "$(git log ^HEAD @{upstream})"; then
-   # We can't just git pull, because that would modify the running script,
-   # which tends to upset bash.  So we'll exec out to the git pull, and try
-   # this script again.
-   #
-   # DONT_PULL_GITALL is a recursion guard, in case of git weirdness.
-   if test ${DONT_PULL_GITALL-no} = no; then
-      echo ">> Updating gitall"
-      exec bash -c "git pull && DONT_PULL_GITALL=yes $0"
-   else
-      cat <<EOF >&2
+    ! test -z "$(git log ^HEAD @{upstream})"; then
+    # We can't just git pull, because that would modify the running script,
+    # which tends to upset bash.  So we'll exec out to the git pull, and try
+    # this script again.
+    #
+    # DONT_PULL_GITALL is a recursion guard, in case of git weirdness.
+    if test ${DONT_PULL_GITALL-no} = no; then
+        echo ">> Updating gitall"
+        exec bash -c "git pull && DONT_PULL_GITALL=yes $0"
+    else
+        cat <<EOF >&2
 
 Cowardly refusing to pull gitall repo and re-run $0.
 Run git pull and try again.
 EOF
-      exit 1
-   fi
+        exit 1
+    fi
 fi
 
 gitdepot=git at git.asterisk.org
@@ -64,33 +64,33 @@ repos[i++]=integration/test_channel
 repos[i++]=release/cmake
 
 for repo in "${repos[@]}"; do
-   repoDir=$(basename ${repo})
-   repoUri=${gitdepot}:${tree}/${repo}
+    repoDir=$(basename ${repo})
+    repoUri=${gitdepot}:${tree}/${repo}
 
-   if [ -d ${repoDir}/.git ]; then
-      if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
-         echo ">> Updating from repo ${repoUri}"
-         ( cd ${repoDir} && git pull )
-      else
-         echo "-- Skipping ${repoDir}; no upstream branch"
-      fi
-   else
-      echo ">> Cloning from ${repoUri} to ${repoDir}"
-      git clone ${repoUri} ${repoDir}
-   fi
-   echo " "
+    if [ -d ${repoDir}/.git ]; then
+        if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
+            echo ">> Updating from repo ${repoUri}"
+            ( cd ${repoDir} && git pull )
+        else
+            echo "-- Skipping ${repoDir}; no upstream branch"
+        fi
+    else
+        echo ">> Cloning from ${repoUri} to ${repoDir}"
+        git clone ${repoUri} ${repoDir}
+    fi
+    echo " "
 done
 
 if [ ! -d pjproject ]; then
-   echo " "
-   echo "--------- "
-   echo "REMINDER: You must manually install pjproject in this directory."
-   echo "  http://www.pjsip.org/download.htm"
-   echo "--------- "
-   echo " "
+    echo " "
+    echo "--------- "
+    echo "REMINDER: You must manually install pjproject in this directory."
+    echo "  http://www.pjsip.org/download.htm"
+    echo "--------- "
+    echo " "
 fi
 
 if test ${kill_agent-no} != no; then
-   echo "killing ssh-agent"
-   kill $SSH_AGENT_PID
+    echo "killing ssh-agent"
+    kill $SSH_AGENT_PID
 fi

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


-- 
asterisk-scf/integration/gitall.git



More information about the asterisk-scf-commits mailing list