: nply/git-summary

commit 73e3565097196a923cdcbddaa5549f32177e61b6
parent 21c9d5af472994a705d5dfa420dfd4fc4f48e646
Author: Tobias at thinkpad home <tobias.witting@posteo.de>
Date: Mon, 14 Oct 2019 07:24:51 +0200

made parallel execution optional
sometimes (e.g. when working over a gate-way) launching multiple commands in quick succession is not good.
2 files changed, 11 insertions(+), 2 deletions(-)
M
README.md
|
1
+
M
git-summary
|
12
++++++++++--
diff --git a/README.md b/README.md
@@ -47,6 +47,7 @@ git-summary [options] path
 * **-l**: Local summary lookup. Checks only local changes which is faster as there is no need to fetch the remote.
 * **-d**: Deep lookup. Look for any git repos within the entire current directory tree. Can be slowish for large trees.
 * **-q**: Quiet mode. Only print outdated repos.
+* **-s**: Run sequentially, do not spawn multiple parallel background jobs.
 
 ## Branch status
 Currently, `git-summary` does not list multiple branches per repo. However, for single repos [`git-branch-status`](https://github.com/bill-auger/git-branch-status) does this beautifully.
diff --git a/git-summary b/git-summary
@@ -52,6 +52,8 @@ usage() {
           -q    Print nothing for repos that are up to date. Also print
                 a final tally.
 
+          -s	Run sequentially, do not spawn multiple parallel background jobs
+
           path  Path to folder containing git repos; if omitted, the
                 current working directory is used.
 

@@ -68,12 +70,14 @@ git_summary() {
     local opt
     local deeplookup=0
     local quiet=0
-    while getopts "hldq" opt; do
+    local sequential=0
+    while getopts "hldqs" opt; do
         case "${opt}" in
             h) usage ; exit 1 ;;
             l) local_only=1 ;;    # Will skip "git fetch"
             d) deeplookup=1 ;;
             q) quiet=1 ;;
+	    s) sequential=1 ;;    # run sequentially
         esac
     done
     shift $((OPTIND-1))

@@ -104,7 +108,11 @@ git_summary() {
 
     local f
     for f in $repos ; do
-        summarize_one_git_repo $f "$template" "$local_only" "$quiet" >&1 &
+	if [ $sequential -eq 0 ] ; then
+	    summarize_one_git_repo $f "$template" "$local_only" "$quiet" >&1 &  # multiple bg jobs
+	else
+	    summarize_one_git_repo $f "$template" "$local_only" "$quiet" >&1    # sequentially
+	fi
         (( repo_count+=1 ))
     done
     wait