From 473c74268182159d15ff41b16a706603a5272028 Mon Sep 17 00:00:00 2001 From: GabrielInTheWorld Date: Wed, 16 Feb 2022 16:19:58 +0100 Subject: [PATCH] Speed up the 'make run-dev' command (#6362) --- Makefile | 2 +- dev-commands/submodules-do.sh | 23 +++++++++++++++++++++++ services-to-main.sh | 6 +++--- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100755 dev-commands/submodules-do.sh diff --git a/Makefile b/Makefile index 633543c69..92acb70b6 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ run-service-tests: git submodule foreach 'make run-tests' build-dev: - git submodule foreach 'make build-dev' + ./dev-commands/submodules-do.sh 'make build-dev' make -C proxy build-dev run-dev: | build-dev diff --git a/dev-commands/submodules-do.sh b/dev-commands/submodules-do.sh new file mode 100755 index 000000000..c940c5182 --- /dev/null +++ b/dev-commands/submodules-do.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# This script runs a command in every registered submodule parallel +# Credits go to https://stackoverflow.com/a/70418086 + +if [ -z "$1" ]; then + echo "Missing Command" >&2 + exit 1 +fi + +COMMAND="$@" + +IFS=$'\n' +for DIR in $(git submodule foreach --recursive -q sh -c pwd); do + printf "\n\"${DIR}\": \"${COMMAND}\" started!\n" \ + && \ + cd "$DIR" \ + && \ + eval "$COMMAND" \ + && \ + printf "\"${DIR}\": \"${COMMAND}\" finished!\n" \ + & +done +wait \ No newline at end of file diff --git a/services-to-main.sh b/services-to-main.sh index b8959b2f3..d19ef48f7 100755 --- a/services-to-main.sh +++ b/services-to-main.sh @@ -23,9 +23,9 @@ function pull_latest_commit { local BRANCH_NAME=$(get_upstream_branch) local REMOTE_NAME=$(get_upstream_name) - echo "git fetch $REMOTE_NAME && git checkout $REMOTE_NAME/$BRANCH_NAME ..." - git fetch $REMOTE_NAME; - git checkout $REMOTE_NAME/$BRANCH_NAME; + echo "git checkout $BRANCH_NAME && git pull $REMOTE_NAME $BRANCH_NAME ..." + git checkout -B $BRANCH_NAME; + git pull $REMOTE_NAME $BRANCH_NAME; } export -f pull_latest_commit