Skip to content

Commit 5dc35f6

Browse files
committed
wrap to 80
1 parent 70c04f1 commit 5dc35f6

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

scripts/setup_quickstart_spm.sh

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ set -euo pipefail
2323
readonly NIGHTLY_RELEASE_TESTING="nightly_release_testing"
2424
readonly PRERELEASE_TESTING="prerelease_testing"
2525

26-
# All script logic is contained in functions. The main function is called at the end.
26+
# All script logic is contained in functions. The main function is called at
27+
# the end.
2728
# Global variables:
2829
# - readonly constants are defined at the top.
2930
# - scripts_dir and root_dir are set after constants.
@@ -38,23 +39,30 @@ Usage: $(basename "$0") <sample_name> [testing_mode]
3839
This script sets up a quickstart sample for SPM integration testing.
3940
4041
ARGUMENTS:
41-
<sample_name> The name of the quickstart sample directory (e.g., "authentication").
42+
<sample_name> The name of the quickstart sample directory
43+
(e.g., "authentication").
4244
[testing_mode] Optional. Specifies the testing mode. Can be one of:
43-
- "${NIGHTLY_RELEASE_TESTING}": Points SPM to the latest CocoaPods tag.
44-
- "${PRERELEASE_TESTING}": Points SPM to the tip of the main branch.
45+
- "${NIGHTLY_RELEASE_TESTING}": Points SPM to the latest
46+
CocoaPods tag.
47+
- "${PRERELEASE_TESTING}": Points SPM to the tip of the main
48+
branch.
4549
- (default): Points SPM to the current commit for PR testing.
4650
4751
ENVIRONMENT VARIABLES:
4852
QUICKSTART_REPO: Optional. Path to a local clone of the quickstart-ios repo.
4953
If not set, the script will clone it from GitHub.
50-
Example: QUICKSTART_REPO=/path/to/quickstart-ios $(basename "$0") authentication
54+
Example:
55+
QUICKSTART_REPO=/path/to/quickstart-ios $(basename "$0") authentication
5156
5257
QUICKSTART_BRANCH: Optional. The branch to checkout in the quickstart repo.
5358
Defaults to the repo's default branch.
54-
Example: QUICKSTART_BRANCH=my-feature-branch $(basename "$0") authentication
59+
Example:
60+
QUICKSTART_BRANCH=my-feature-branch $(basename "$0") authentication
5561
56-
BYPASS_SECRET_CHECK: Optional. Set to "true" to bypass the CI secret check for local runs.
57-
Example: BYPASS_SECRET_CHECK=true $(basename "$0") authentication
62+
BYPASS_SECRET_CHECK: Optional. Set to "true" to bypass the CI secret check
63+
for local runs.
64+
Example:
65+
BYPASS_SECRET_CHECK=true $(basename "$0") authentication
5866
5967
DEBUG: Optional. Set to "true" to enable shell trace mode (`set -x`).
6068
Example: DEBUG=true $(basename "$0") authentication
@@ -77,13 +85,16 @@ setup_quickstart_repo() {
7785
if [[ -n "${QUICKSTART_REPO:-}" ]]; then
7886
# If the user provided a path, it must be a valid directory.
7987
if [[ ! -d "${QUICKSTART_REPO}" ]]; then
80-
echo "Error: QUICKSTART_REPO is set to '${QUICKSTART_REPO}', but this is not a valid directory." >&2
88+
echo "Error: QUICKSTART_REPO is set to '${QUICKSTART_REPO}'," \
89+
"but this is not a valid directory." >&2
8190
exit 1
8291
fi
8392
echo "Using local quickstart repository at ${QUICKSTART_REPO}" >&2
8493
quickstart_dir="${QUICKSTART_REPO}"
85-
if ! (cd "${quickstart_dir}" && git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
86-
echo "Error: QUICKSTART_REPO ('${quickstart_dir}') is not a git repository." >&2
94+
if ! (cd "${quickstart_dir}" && \
95+
git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
96+
echo "Error: QUICKSTART_REPO ('${quickstart_dir}') is not a git" \
97+
"repository." >&2
8798
exit 1
8899
fi
89100
else
@@ -95,7 +106,8 @@ setup_quickstart_repo() {
95106
echo "Cloning quickstart repository into '${quickstart_dir}' directory..." >&2
96107
# Do a partial, sparse clone to speed up CI. See
97108
# https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
98-
git clone --filter=blob:none --sparse https://github.com/firebase/quickstart-ios.git "${quickstart_dir}"
109+
git clone --filter=blob:none --sparse \
110+
https://github.com/firebase/quickstart-ios.git "${quickstart_dir}"
99111
fi
100112
(
101113
cd "${quickstart_dir}"
@@ -137,29 +149,34 @@ update_spm_dependency() {
137149
"${NIGHTLY_RELEASE_TESTING}")
138150
# For release testing, find the latest CocoaPods tag.
139151
local latest_tag
140-
latest_tag=$(git -C "$root_dir" tag -l "CocoaPods-*" --sort=-v:refname | awk '/^CocoaPods-[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }')
152+
latest_tag=$(git -C "$root_dir" tag -l "CocoaPods-*" --sort=-v:refname | \
153+
awk '/^CocoaPods-[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }')
141154
if [[ -z "$latest_tag" ]]; then
142155
echo "Error: Could not find a 'CocoaPods-X.Y.Z' tag." >&2
143156
exit 1
144157
fi
145158
local tag_revision
146159
tag_revision=$(git -C "$root_dir" rev-list -n 1 "$latest_tag")
147-
echo "Setting SPM dependency to revision for tag ${latest_tag}: ${tag_revision}"
148-
"$scripts_dir/update_firebase_spm_dependency.sh" "$absolute_project_file" --revision "$tag_revision"
160+
echo "Setting SPM dependency to revision for tag ${latest_tag}:" \
161+
"${tag_revision}"
162+
"$scripts_dir/update_firebase_spm_dependency.sh" \
163+
"$absolute_project_file" --revision "$tag_revision"
149164
;;
150165

151166
"${PRERELEASE_TESTING}")
152167
# For prerelease testing, point to the tip of the main branch.
153168
echo "Setting SPM dependency to the tip of the main branch."
154-
"$scripts_dir/update_firebase_spm_dependency.sh" "$absolute_project_file" --prerelease
169+
"$scripts_dir/update_firebase_spm_dependency.sh" \
170+
"$absolute_project_file" --prerelease
155171
;;
156172

157173
*)
158174
# For PR testing, point to the current commit.
159175
local current_revision
160176
current_revision=$(git -C "$root_dir" rev-parse HEAD)
161177
echo "Setting SPM dependency to current revision: ${current_revision}"
162-
"$scripts_dir/update_firebase_spm_dependency.sh" "$absolute_project_file" --revision "$current_revision"
178+
"$scripts_dir/update_firebase_spm_dependency.sh" \
179+
"$absolute_project_file" --revision "$current_revision"
163180
;;
164181
esac
165182
}
@@ -196,8 +213,9 @@ main() {
196213
# Source function to check if CI secrets are available.
197214
source "$scripts_dir/check_secrets.sh"
198215

199-
# Some quickstarts may not need a real GoogleService-Info.plist for their tests.
200-
# When QUICKSTART_REPO is set, we are running locally and should skip the secrets check.
216+
# Some quickstarts may not need a real GoogleService-Info.plist for their
217+
# tests. When QUICKSTART_REPO is set, we are running locally and should skip
218+
# the secrets check.
201219
if [[ -z "${QUICKSTART_REPO:-}" ]] && \
202220
[[ "${BYPASS_SECRET_CHECK:-}" != "true" ]] && \
203221
! check_secrets && \
@@ -219,13 +237,15 @@ main() {
219237

220238
# Find the .xcodeproj file within the sample directory.
221239
# Fail if there isn't exactly one.
222-
# Enable nullglob to ensure the glob expands to an empty list if no files are found.
240+
# Enable nullglob to ensure the glob expands to an empty list if no files
241+
# are found.
223242
shopt -s nullglob
224243
local project_files=("${quickstart_project_dir}"/*.xcodeproj)
225244
# Restore default globbing behavior.
226245
shopt -u nullglob
227246
if [[ "${#project_files[@]}" -ne 1 ]]; then
228-
echo "Error: Expected 1 .xcodeproj file in '${quickstart_project_dir}', but found ${#project_files[@]}." >&2
247+
echo "Error: Expected 1 .xcodeproj file in" \
248+
"'${quickstart_project_dir}', but found ${#project_files[@]}." >&2
229249
exit 1
230250
fi
231251
local project_file="${project_files[0]}"
@@ -234,4 +254,4 @@ main() {
234254
}
235255

236256
# Run the main function with all provided arguments.
237-
main "$@"
257+
main "$@"

0 commit comments

Comments
 (0)