[asterisk-scf-commits] asterisk-scf/integration/gitall.git branch "reduce-output" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Jan 3 17:37:20 UTC 2011
branch "reduce-output" has been created
at 4cee58dec6008ea8d3ba7018cc617413561da0ba (commit)
- Log -----------------------------------------------------------------
commit 4cee58dec6008ea8d3ba7018cc617413561da0ba
Author: David M. Lee <dlee at digium.com>
Date: Sat Jan 1 03:27:52 2011 -0600
Reduced duplication in git output.
Many of the git commands actually produce the same output across all of
our repos. To reduce verbosity in the output, I added a function which
omits printing duplicate messages.
diff --git a/.gitignore b/.gitignore
index 972ef15..b84cdff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ sip
slice
test_channel
ice-util-cpp
+.gitall.*
diff --git a/gitall-asterisk-scf.sh b/gitall-asterisk-scf.sh
index 636a2ab..b17ff58 100755
--- a/gitall-asterisk-scf.sh
+++ b/gitall-asterisk-scf.sh
@@ -25,6 +25,31 @@ If no command is given, pull is run by default.
EOF
}
+# a temp file for holding the output of git commands for later comparison
+last_text_file=$(mktemp .gitall.XXXXXX)
+if test $? -ne 0; then
+ echo "Failed to create temp file" >&2
+ exit 1
+fi
+
+# on exit, cat the last output and delete the temp file
+trap "cat ${last_text_file}; rm -f ${last_text_file}" EXIT
+
+# collapse multiple identical inputs into a single input
+function collapse()
+{
+ # first line is a header; always print
+ head="$(head -n 1)"
+ # rest is the text. add a line for spacing.
+ new_text="$(cat && echo ' ')"
+
+ if test "${new_text}" != "$(cat ${last_text_file})"; then
+ cat ${last_text_file}
+ echo "${new_text}" > ${last_text_file}
+ fi
+ echo "${head}"
+}
+
gitdepot=`git config --get remote.origin.url | sed "s at asterisk-scf/integration/gitall@@"`
gitdepot_push=`git config --get remote.origin.pushurl | sed "s at asterisk-scf/integration/gitall@@"`
@@ -89,9 +114,10 @@ function pull()
fi
# check to see if gitall needs a pull
- echo ">> Fetching gitall"
- git fetch
- echo
+ {
+ echo ">> Fetching gitall"
+ git fetch
+ } 2>&1 | collapse
# if there is an upstream branch, and it has changes we don't
if git rev-parse --verify @{upstream} > /dev/null 2>&1 &&
@@ -131,29 +157,30 @@ EOF
fi
for repo in "${repos[@]}"; do
- repoDir=$(basename ${repo})
- repoUri=${gitdepot}${tree}/${repo}
- repoPushUri=${gitdepot_push}${tree}/${repo}
-
- if [ -d ${repoDir}/.git ]; then
- # update the origin to what is specified in repoUri
- ( cd ${repoDir} && git config remote.origin.url ${repoUri} )
- ( cd ${repoDir} && if test ${gitdepot_push}; then
- git config remote.origin.pushurl ${repoPushUri};
+ {
+ repoDir=$(basename ${repo})
+ repoUri=${gitdepot}${tree}/${repo}
+ repoPushUri=${gitdepot_push}${tree}/${repo}
+
+ if [ -d ${repoDir}/.git ]; then
+ # update the origin to what is specified in repoUri
+ ( cd ${repoDir} && git config remote.origin.url ${repoUri} )
+ ( cd ${repoDir} && if test ${gitdepot_push}; then
+ git config remote.origin.pushurl ${repoPushUri};
+ else
+ git config --unset remote.origin.pushurl
+ fi )
+ if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
+ echo ">> Pulling from repo ${repoUri}"
+ ( cd ${repoDir} && git pull )
else
- git config --unset remote.origin.pushurl
- fi )
- if ( cd ${repoDir} && git rev-parse --verify @{upstream} > /dev/null 2>&1 ); then
- echo ">> Pulling from repo ${repoUri}"
- ( cd ${repoDir} && git pull )
+ echo "-- Skipping ${repoDir}; no upstream branch"
+ fi
else
- echo "-- Skipping ${repoDir}; no upstream branch"
+ echo ">> Cloning from ${repoUri} to ${repoDir}"
+ git clone ${repoUri} ${repoDir}
fi
- else
- echo ">> Cloning from ${repoUri} to ${repoDir}"
- git clone ${repoUri} ${repoDir}
- fi
- echo " "
+ } 2>&1 | collapse
done
# Make sure that config_site.h exists for Windows.
@@ -165,21 +192,22 @@ EOF
function passthrough()
{
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" "$@" "(${repoName})"
- ( cd ${repoDir} && git "$@" )
- if test $? -ne 0; then
- echo >&2
- echo "!! Failed to tag ${repoName}." >&2
- exit 1
- fi
- echo
+ {
+ 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" "$@" "(${repoName})"
+ ( cd ${repoDir} && git "$@" )
+ if test $? -ne 0; then
+ echo >&2
+ echo "!! Failed to tag ${repoName}." >&2
+ exit 1
+ fi
+ } 2>&1 | collapse
done
} # passthrough
@@ -203,15 +231,16 @@ function dry_run()
echo
for repo in . "${repos[@]}"; do
- repoDir=$(basename ${repo})
- repoName=$(basename "$(cd ${repoDir} && pwd)")
- echo ">> git" "$@" "(${repoName})"
- ( cd ${repoDir} && git "$@" )
- if test $? -ne 0; then
- echo "!! Failed to push ${repoName}." >&2
- exit 1
- fi
- echo
+ {
+ repoDir=$(basename ${repo})
+ repoName=$(basename "$(cd ${repoDir} && pwd)")
+ echo ">> git" "$@" "(${repoName})"
+ ( cd ${repoDir} && git "$@" )
+ if test $? -ne 0; then
+ echo "!! Failed to push ${repoName}." >&2
+ exit 1
+ fi
+ } 2>&1 | collapse
done
} # dry_run
-----------------------------------------------------------------------
--
asterisk-scf/integration/gitall.git
More information about the asterisk-scf-commits
mailing list