#!/usr/bin/env bash# The commit a bundle is built from, the way it is stamped as `CottonBuildCommit`:# nine characters of HEAD, plus `+changes` when the tree has edits nobody# committed — the Mac's `apps/cotton/scripts/build-app.sh` rule, said once for# the phone's local runners (`ios-install-device.sh`, `ios-launch-smoke.sh`),# which pass it to xcodebuild as `COTTON_BUILD_COMMIT=<this>` (`project.yml`).# Empty outside a git checkout: nothing is stamped rather than a guess.## source "$ROOT/scripts/lib/build-commit.sh"; COMMIT="$(cotton_build_commit "$ROOT")"cotton_build_commit() {local root="$1" commit commit="$(git -C "$root" rev-parse --short=9 HEAD 2>/dev/null || true)" [ -n "$commit" ] || return0if ! git -C "$root" diff --quiet HEAD -- 2>/dev/null; then commit="$commit+changes"; fi printf '%s'"$commit"}