- The Pods/ directory always exists even before submodules have been initialized; check for Pods/.git instead, which may be a file or a folder depending on how the submodule was set up. - When cloning for the first time, make sure the remote is called 'private' so that later updates will reference it correctly. Also run `git submodule absorbgitdirs` so that git stores the submodule state inside the top-level .git directory. - For an existing directory, simplify the check for the presence of a proper 'private' remote. - Check that we're running from the repository root so we don't get weird errors or do random clones. - Make the script Shellcheck-clean.
35 lines
1.4 KiB
Bash
Executable File
35 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# shellcheck disable=SC2164 # pushd/popd failure
|
|
|
|
if [ ! -d Signal.xcodeproj ]; then
|
|
echo "error: Must be run from the repository root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "${USE_PRIVATE_PODS+x}" ]; then
|
|
echo "Using private pods"
|
|
if [ -e "Pods/.git" ]; then
|
|
pushd Pods
|
|
# FIXME: Possible failure modes here:
|
|
# - You have a Signal-Pods-Private remote not named 'private'.
|
|
# - You have a remote named 'private' that points somewhere else.
|
|
if ! git remote -v | grep -qi 'signal-pods-private'; then
|
|
echo "Adding private pods remote"
|
|
git remote add private git@github.com:signalapp/Signal-Pods-Private.git
|
|
fi
|
|
git fetch private
|
|
popd
|
|
else
|
|
echo "Cloning private pods repo"
|
|
git clone git@github.com:signalapp/Signal-Pods-Private.git -o private Pods
|
|
# Add the public repo as a remote explicitly.
|
|
# This is what would happen if you did `git submodule update --init` first,
|
|
# and it helps avoid confusing Jenkins for the nightly builder.
|
|
git -C Pods remote add origin git@github.com:signalapp/Signal-Pods.git
|
|
# Not strictly necessary, but consistent with doing `git submodule update --init` first.
|
|
git submodule absorbgitdirs Pods
|
|
fi
|
|
else
|
|
echo "Not using private pods. Define USE_PRIVATE_PODS in your environment to enable."
|
|
fi
|