ClickHouse/contrib/update-submodules.sh

31 lines
1.3 KiB
Bash
Raw Normal View History

2023-03-29 16:33:15 +00:00
#!/bin/sh
set -e
2023-11-09 11:39:50 +00:00
SCRIPT_PATH=$(realpath "$0")
2023-11-09 14:25:59 +00:00
SCRIPT_DIR=$(dirname "${SCRIPT_PATH}")
GIT_DIR=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)
2023-11-09 11:39:50 +00:00
cd $GIT_DIR
2023-03-29 16:33:15 +00:00
2024-01-18 18:21:26 +00:00
# Exclude from contribs some garbage subdirs that we don't need.
# It reduces the checked out files size about 3 times and therefore speeds up indexing in IDEs and searching.
# NOTE .git/ still contains everything that we don't check out (although, it's compressed)
# See also https://git-scm.com/docs/git-sparse-checkout
2023-11-09 11:39:50 +00:00
contrib/sparse-checkout/setup-sparse-checkout.sh
2024-01-18 18:21:26 +00:00
2023-03-29 16:33:15 +00:00
git submodule init
git submodule sync
2024-01-18 18:21:26 +00:00
# NOTE: do not use --remote for `git submodule update`[1] command, since the submodule references to the specific commit SHA1 in the subproject.
# It may cause unexpected behavior. Instead you need to commit a new SHA1 for a submodule.
#
# [1] - https://git-scm.com/book/en/v2/Git-Tools-Submodules
git config --file .gitmodules --get-regexp '.*path' | sed 's/[^ ]* //' | xargs -I _ --max-procs 64 git submodule update --depth=1 --single-branch _
# We don't want to depend on any third-party CMake files.
# To check it, find and delete them.
grep -o -P '"contrib/[^"]+"' .gitmodules |
grep -v -P 'contrib/(llvm-project|google-protobuf|grpc|abseil-cpp|corrosion)' |
xargs -I@ find @ \
-'(' -name 'CMakeLists.txt' -or -name '*.cmake' -')' -and -not -name '*.h.cmake' \
-delete