X-Git-Url: http://git.sthu.org/?a=blobdiff_plain;f=git%2Fgit-pull-all;h=d63e73c9061ebb7a06bc6c4e92afc30a5d490c36;hb=d4d771618824ada5d34f22031e3748de27cd68b5;hp=521c26c6a84db1a1809e8497dc66b5b7d656e5ea;hpb=57933f3a209b3a2d5163cb617dcdd09904a02d40;p=shutils.git diff --git a/git/git-pull-all b/git/git-pull-all index 521c26c..d63e73c 100755 --- a/git/git-pull-all +++ b/git/git-pull-all @@ -28,15 +28,32 @@ set -e set -u -function showHelp +showHelp() { - echo "Usage: $0 [-h|--help]" - echo " $0 [OPTIONS]" + echo "Recursively pull git repositories behind origin." + echo "" + echo "Usage:" + echo " git-pull-all [OPTIONS]" + echo " git-pull-all [OPTIONS] DIR" echo "" echo "OPTIONS:" - echo " -a, --ask ask user for each repo" - echo " -h, --help show this message" - echo " -n, --dry-run do not actually perform pull" + echo " -a, --ask ask user for each repo before pull" + echo " -h, --help show this message" + echo " -n, --dry-run do not actually perform pull" + echo "" + echo "" + echo "Examples:" + echo "" + echo "Recursively find git repositories and invoke pull if" + echo "branch is behind origin:" + echo "" + echo " git-pull-all" + echo "" + echo "Find git repositories in home directory and print" + echo "whether they are up to date:" + echo "" + echo " git-pull-all -n ~" + } if ! options=$(getopt -u -o ahn -l ask,help,dry-run -- "$@"); then @@ -64,7 +81,7 @@ done for REPODIR in $(find "$@" -name .git -type d 2> /dev/null); do REPO=$(dirname ${REPODIR}) - echo "Run ${REPO}…" + echo "Run ${REPO} …" if [ "${optAsk}" = 1 ]; then read -p " Process [y/N]? " -n1 response @@ -76,9 +93,12 @@ for REPODIR in $(find "$@" -name .git -type d 2> /dev/null); do git -C ${REPO} remote update if [ -z "$(git -C ${REPO} status -uno | grep 'Your branch is behind')" ] ; then - echo -e "\e[1;32m Already up to date\e[0m" + /usr/bin/echo -e "\e[1;32m Already up to date\e[0m" else - [ "${optDryRun}" = 1 ] && continue + if [ "${optDryRun}" = 1 ]; then + /usr/bin/echo -e "\e[1;31m Skipping due to dry-run\e[0m" + continue + fi git -C ${REPO} pull fi