Skip to content

Commit d610048

Browse files
committed
Do submodule update and upgrade operations in parallel
1 parent 93cd1bb commit d610048

File tree

5 files changed

+19
-32
lines changed

5 files changed

+19
-32
lines changed

commands/.settings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ if [ "$GIT_QUIET" = 0 ]; then
1717
else
1818
GIT_QUIET=(--quiet)
1919
fi
20+
21+
N_PARALLEL_UPDATE="${N_PARALLEL_UPDATE:-$NUMBER_OF_PROCESSORS}"

commands/clone

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ fi
1616
NAME="${1%.git}"
1717
NAME="${NAME##*/}"
1818

19-
N_PARALLEL_UPDATE="${N_PARALLEL_UPDATE:-$NUMBER_OF_PROCESSORS}"
20-
2119
git clone "${GIT_QUIET[@]}" --branch "$2" "$1"
2220
cd "$NAME"
2321
git submodule "${GIT_QUIET[@]}" update --init --jobs "$N_PARALLEL_UPDATE"

commands/update

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ fi
1616

1717
git pull "${GIT_QUIET[@]}" --rebase
1818

19-
update-by-key () {
20-
local KEY="$1"
21-
local DIR
22-
DIR="$(git config --file .gitmodules --get "$KEY")"
23-
git submodule "${GIT_QUIET[@]}" update --init -- "$DIR"
24-
}
19+
MODULES=()
20+
while IFS='' read -r line; do
21+
MODULES+=("$line")
22+
done < <(git config \
23+
--file .gitmodules \
24+
--get-regexp "^submodule\.(equipment|requires)/.*\.path$" \
25+
| sed -e 's#^.*\.path ##g')
2526

26-
for KEY in $(git config \
27-
--file .gitmodules \
28-
--name-only \
29-
--get-regexp "^submodule\.(equipment|requires)/.*\.path$"); do
30-
update-by-key "$KEY"
31-
done
32-
33-
update-by-key "submodule..cppsm.path"
27+
git submodule "${GIT_QUIET[@]}" update --jobs "$N_PARALLEL_UPDATE" --init -- "${MODULES[@]}"

commands/upgrade

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,15 @@ EOF
1414
exit 1
1515
fi
1616

17-
upgrade-by-key () {
18-
local KEY="$1"
19-
local DIR
20-
DIR="$(git config --file .gitmodules --get "$KEY")"
21-
git submodule "${GIT_QUIET[@]}" update --remote -- "$DIR"
22-
git add "$DIR"
23-
}
17+
MODULES=()
18+
while IFS='' read -r line; do
19+
MODULES+=("$line")
20+
done < <(git config \
21+
--file .gitmodules \
22+
--get-regexp "^submodule\.(equipment|requires)/.*\.path$" \
23+
| sed -e 's#^.*\.path ##g')
2424

25-
for KEY in $(git config \
26-
--file .gitmodules \
27-
--name-only \
28-
--get-regexp "^submodule\.(equipment|requires)/.*\.path$"); do
29-
upgrade-by-key "$KEY"
30-
done
31-
32-
upgrade-by-key "submodule..cppsm.path"
25+
git submodule "${GIT_QUIET[@]}" update --jobs "$N_PARALLEL_UPDATE" --remote -- "${MODULES[@]}"
26+
git add "${MODULES[@]}"
3327

3428
"$CPPSM/commands/init"

travis-ci

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ folded() {
5555
echo -e "\ntravis_fold:end:cppsm.$FOLD\r"
5656
}
5757

58-
N_PARALLEL_UPDATE="${N_PARALLEL_UPDATE:-$NUMBER_OF_PROCESSORS}"
5958
folded ... concurrently GIT_UPDATE_PID git submodule update --init --depth 1 --jobs "$N_PARALLEL_UPDATE"
6059

6160
if [ "$TRAVIS_OS_NAME" = linux ]; then

0 commit comments

Comments
 (0)