Skip to content

Commit 4b0cb73

Browse files
committed
[yugabyte#8568] Remove the yugabyte-bash-common submodule
Summary: Submodules make it difficult to switch branches because the submodule stays behind at its old commit. We currently only have one submodule left, yugabyte-bash-common, and we can check it out from our scripts at the required commit instead of using the submodule mechanism. Test Plan: Jenkins: compile only, platform: linux Reviewers: jason, steve.varnau, jharveysmith Reviewed By: steve.varnau, jharveysmith Subscribers: ybase Differential Revision: https://phabricator.dev.yugabyte.com/D11695
1 parent eac38af commit 4b0cb73

File tree

6 files changed

+55
-72
lines changed

6 files changed

+55
-72
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ rrdiagram*.jar*
103103
target/
104104

105105
thirdparty/
106+
107+
# We don't use any submodules anymore.
108+
submodules/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/undo_submodule_changes.sh

Lines changed: 0 additions & 58 deletions
This file was deleted.

build-support/common-build-env.sh

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fi
3030
readonly YB_COMMON_BUILD_ENV_SOURCED=1
3131

3232
# -------------------------------------------------------------------------------------------------
33-
# Initialize submodules and load yugabyte-bash-common
33+
# Functions used during initialization
3434
# -------------------------------------------------------------------------------------------------
3535

3636
set_yb_src_root() {
@@ -44,23 +44,64 @@ set_yb_src_root() {
4444
yb_java_project_dirs=( "$YB_SRC_ROOT/java" )
4545
}
4646

47+
# Puts the current Git SHA1 in the current directory into the current_sha1 variable.
48+
# Remember, this variable could also be local to the calling function.
49+
get_current_sha1() {
50+
current_sha1=$( git rev-parse HEAD )
51+
if [[ ! $current_sha1 =~ ^[0-9a-f]{40}$ ]]; then
52+
# We can't use the "fatal" function yet.
53+
echo >&2 "Could not get current Git SHA1 in $PWD"
54+
exit 1
55+
fi
56+
}
57+
58+
initialize_yugabyte_bash_common() {
59+
local target_sha1=$(<"$YB_SRC_ROOT/build-support/yugabyte-bash-common-sha1.txt")
60+
if [[ ! $target_sha1 =~ ^[0-9a-f]{40}$ ]]; then
61+
echo >&2 "Invalid yugabyte-bash-common SHA1: $sha1"
62+
exit 1
63+
fi
64+
65+
# Put this submodule-like directory under "build".
66+
YB_BASH_COMMON_DIR=$YB_SRC_ROOT/build/yugabyte-bash-common
67+
68+
if [[ ! -d $YB_BASH_COMMON_DIR ]]; then
69+
mkdir -p "$YB_SRC_ROOT/build"
70+
git clone https://github.com/yugabyte/yugabyte-bash-common.git "$YB_BASH_COMMON_DIR"
71+
fi
72+
73+
pushd "$YB_BASH_COMMON_DIR" >/dev/null
74+
local current_sha1
75+
get_current_sha1
76+
if [[ $current_sha1 != $target_sha1 ]]; then
77+
if ! ( set -x; git checkout "$target_sha1" ); then
78+
(
79+
set -x
80+
git fetch
81+
git checkout "$target_sha1"
82+
)
83+
fi
84+
get_current_sha1
85+
if [[ $current_sha1 != $target_sha1 ]]; then
86+
echo >&2 "Failed to check out target SHA1 $target_sha1 in directory $PWD." \
87+
"Current SHA1: $current_sha1."
88+
exit 1
89+
fi
90+
fi
91+
popd >/dev/null
92+
}
93+
4794
# This script is expected to be in build-support, a subdirectory of the repository root directory.
4895
set_yb_src_root "$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
4996

5097
if [[ $YB_SRC_ROOT == */ ]]; then
5198
fatal "YB_SRC_ROOT ends with '/' (not allowed): '$YB_SRC_ROOT'"
5299
fi
53100

54-
YB_BASH_COMMON_DIR=$YB_SRC_ROOT/submodules/yugabyte-bash-common
55-
56-
# Initialize submodules. Only do this when the source directory is a git directory.
57-
if [[ ! -d $YB_BASH_COMMON_DIR || -z "$( ls -A "$YB_BASH_COMMON_DIR" )" ]] &&
58-
[[ -d $YB_SRC_ROOT/.git ]]; then
59-
( cd "$YB_SRC_ROOT"; git submodule update --init --recursive )
60-
fi
101+
initialize_yugabyte_bash_common
61102

62-
# shellcheck source=submodules/yugabyte-bash-common/src/yugabyte-bash-common.sh
63-
. "$YB_SRC_ROOT/submodules/yugabyte-bash-common/src/yugabyte-bash-common.sh"
103+
# shellcheck source=build/yugabyte-bash-common/src/yugabyte-bash-common.sh
104+
. "$YB_BASH_COMMON_DIR/src/yugabyte-bash-common.sh"
64105

65106
# -------------------------------------------------------------------------------------------------
66107
# Constants
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6a2bb7829238175b3ff86dc6d49796435baf6f88

submodules/yugabyte-bash-common

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)