commit 9ffd54d7caec31c62b0a71897a2df7dc03272b6a
parent 96b6162c86ecd1be0f99d7290b4620584e9bac8e
Author: Paul M. Rodriguez <pmr@ruricolist.com>
Date: Thu, 14 Jun 2018 17:54:22 -0500
parent 96b6162c86ecd1be0f99d7290b4620584e9bac8e
Author: Paul M. Rodriguez <pmr@ruricolist.com>
Date: Thu, 14 Jun 2018 17:54:22 -0500
Enable printing nothing for up-to-date repositories.
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/git-summary b/git-summary @@ -19,7 +19,7 @@ usage() { sed 's/^ //' <<EOF git-summary - summarize git repos at some path - Usage: git-summary.sh [-h] [-l] [-d] [path] + Usage: git-summary.sh [-h] [-l] [-d] [-q] [path] Given a path to a folder containing one or more git repos, print a status summary table showing, for each repo: @@ -49,6 +49,9 @@ usage() { -d Deep lookup. Will search within the entire tree of the current folder. + -q Print nothing for repos that are up to date. Also print + a final tally. + path Path to folder containing git repos; if omitted, the current working directory is used. @@ -64,11 +67,13 @@ git_summary() { local local_only=0 local opt local deeplookup=0 - while getopts "hld" opt; do + local quiet=0 + while getopts "hldq" opt; do case "${opt}" in h) usage ; exit 1 ;; l) local_only=1 ;; # Will skip "git fetch" d) deeplookup=1 ;; + q) quiet=1 ;; esac done shift $((OPTIND-1)) @@ -95,11 +100,19 @@ git_summary() { local template=$(printf "%%b%%-%ds %%-%ds %%-5s" $max_repo_len $max_branch_len) print_header "$template" $max_repo_len $max_branch_len + local repo_count=0 + local f for f in $repos ; do - summarize_one_git_repo $f "$template" "$local_only" >&1 & + summarize_one_git_repo $f "$template" "$local_only" "$quiet" >&1 & + (( repo_count+=1 )) done wait + + if [ $quiet -eq 1 ]; then + echo "Checked ${repo_count} repositories." + fi + } # Autodetect the OS @@ -167,6 +180,7 @@ summarize_one_git_repo () { local f=$1 local template=$2 local local_only=$3 + local quiet=$4 local app_name=$f local branch_name=`gitC $f symbolic-ref HEAD | sed -e "s/^refs\/heads\///"` @@ -230,7 +244,9 @@ summarize_one_git_repo () { ### Print to stdout if [ $numState -eq 0 ]; then - printf "$template\n" $GREEN $app_name $branch_name "$state$rstate" >&1 + if [ $quiet -eq 0 ]; then + printf "$template\n" $GREEN $app_name $branch_name "$state$rstate" >&1 + fi elif [ $numState -eq 1 ]; then printf "$template\n" $ORANGE $app_name $branch_name "$state$rstate" >&1 elif [ $numState -eq 2 ]; then
: nply/git-summary