File tree Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Expand file tree Collapse file tree 1 file changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -9,20 +9,51 @@ ARGS=${*:-status --branch --short}
9
9
10
10
NUM=" $( echo $REPOS | wc -w) "
11
11
I=0
12
+ running_jobs=0
13
+ MAX_PARALLEL=4
14
+ tmp_files=()
15
+
16
+ function run_git_command {
17
+ local dir=$1
18
+ local args=$2
19
+ local tmp_file=$3
20
+ git -c color.status=always -C " $dir " $args >> " $tmp_file " 2>&1 &
21
+ }
22
+
12
23
for D in $REPOS ; do
13
24
I=$(( $I + 1 ))
14
- echo " "
15
- echo " ------------ ( $I / $NUM ) $D ------------"
16
25
FULL_DIR=" $BASEDIR /$D "
17
26
if [ " $ARGS " == " walk" ]; then
27
+ echo " ------------- ( $I / $NUM ) $D -------------"
18
28
pushd $FULL_DIR
19
29
git status
20
30
bash
21
31
popd
22
32
else
23
- git -C " $FULL_DIR " $ARGS
33
+ tmp_file=$( mktemp)
34
+ tmp_files+=(" $tmp_file " )
35
+ echo " ------------- ( $I / $NUM ) $D -------------" > " $tmp_file "
36
+ echo " -- Started -- ( $I / $NUM ) $D -------------"
37
+ run_git_command " $FULL_DIR " " $ARGS " " $tmp_file "
38
+
39
+ (( running_jobs++ ))
40
+ if (( running_jobs >= MAX_PARALLEL )) ; then
41
+ wait -n
42
+ (( running_jobs-- ))
43
+ fi
24
44
fi
25
45
done
26
- if [ " $ARGS " == " walk" ]; then
27
- echo " ------------ DONE ------------"
46
+
47
+ if [ " $ARGS " != " walk" ]; then
48
+ wait
28
49
fi
50
+
51
+ echo " ------------- DONE -------------"
52
+
53
+ # Print the buffered output
54
+ for tmp_file in " ${tmp_files[@]} " ; do
55
+ echo " "
56
+ cat " $tmp_file "
57
+ rm " $tmp_file "
58
+ done
59
+
You can’t perform that action at this time.
0 commit comments