9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
94 lines
4.1 KiB
Bash
94 lines
4.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Writes worktree-aware identity overrides for mobile debug builds, mirroring
|
|
# the desktop dev experience in scripts/instance-env.sh: debug builds produced
|
|
# from a git worktree get a unique app identifier keyed to the WORKTREE
|
|
# DIRECTORY NAME (stable across branch switches, so installs and login state
|
|
# are bounded by worktree count) plus a display-only branch label (short SHA
|
|
# when detached).
|
|
#
|
|
# In a worktree this writes two gitignored override files consumed by the
|
|
# native build systems (so direct Xcode / Android Studio / `flutter run`
|
|
# builds pick them up too):
|
|
# mobile/ios/Flutter/WorktreeOverrides.xcconfig (Debug builds only; a
|
|
# developer's AppOverrides.xcconfig takes precedence per variable)
|
|
# mobile/android/worktree.properties (debug build type only)
|
|
# In the main checkout it removes any stale override files. Release and
|
|
# profile builds never read these overrides.
|
|
set -euo pipefail
|
|
|
|
# `just mobile-*` recipes unset these before invoking Flutter; do the same so
|
|
# an inherited GIT_DIR pointing elsewhere cannot misdetect the worktree.
|
|
unset GIT_DIR GIT_WORK_TREE
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ios_overrides="$repo_root/mobile/ios/Flutter/WorktreeOverrides.xcconfig"
|
|
android_props="$repo_root/mobile/android/worktree.properties"
|
|
|
|
# Worktree detection: in the main working tree --git-dir and --git-common-dir
|
|
# are identical; in any linked worktree they differ (same check as
|
|
# scripts/instance-env.sh).
|
|
in_worktree=0
|
|
if git -C "$repo_root" rev-parse --is-inside-work-tree &>/dev/null; then
|
|
git_dir=$(git -C "$repo_root" rev-parse --git-dir)
|
|
git_common_dir=$(git -C "$repo_root" rev-parse --git-common-dir 2>/dev/null)
|
|
if [[ -n "$git_common_dir" && "$git_dir" != "$git_common_dir" ]]; then
|
|
in_worktree=1
|
|
fi
|
|
fi
|
|
|
|
if [[ "$in_worktree" != "1" ]]; then
|
|
rm -f "$ios_overrides" "$android_props"
|
|
exit 0
|
|
fi
|
|
|
|
# Install identity comes from the worktree directory name: stable across
|
|
# branch switches, so one worktree keeps one installed app (and its login
|
|
# state) no matter how many branches it visits.
|
|
worktree_name="$(basename "$repo_root")"
|
|
|
|
# Display label is context only: the branch name, or a short SHA when the
|
|
# worktree is detached. Sanitized to [A-Za-z0-9._-] so no valid Git ref can
|
|
# break Android string resources or xcconfig values.
|
|
branch=$(git -C "$repo_root" rev-parse --abbrev-ref HEAD)
|
|
if [[ "$branch" == "HEAD" ]]; then
|
|
label_raw=$(git -C "$repo_root" rev-parse --short HEAD)
|
|
else
|
|
label_raw="${branch##*/}"
|
|
fi
|
|
label=$(printf '%s' "$label_raw" | sed -e 's/[^A-Za-z0-9._-]/-/g' -e 's/--*/-/g' -e 's/^-//' -e 's/-$//')
|
|
[[ -n "$label" ]] || label="worktree"
|
|
|
|
# iOS bundle-identifier slug: lowercase, non-alphanumerics collapsed to
|
|
# hyphens (hyphens are valid in bundle identifiers).
|
|
ios_slug=$(printf '%s' "$worktree_name" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z0-9]/-/g' -e 's/--*/-/g' -e 's/^-//' -e 's/-$//')
|
|
[[ -n "$ios_slug" ]] || ios_slug="worktree"
|
|
|
|
# Android applicationId segments must match [a-z][a-z0-9_]*: swap hyphens for
|
|
# underscores and prefix a letter when the slug starts with a digit.
|
|
android_slug="${ios_slug//-/_}"
|
|
case "$android_slug" in
|
|
[0-9]*) android_slug="w_$android_slug" ;;
|
|
esac
|
|
|
|
ios_bundle_id="com.buzz.buzzMobile.${ios_slug}"
|
|
android_suffix=".${android_slug}"
|
|
|
|
cat > "$ios_overrides" <<XCCONFIG
|
|
// Generated by scripts/mobile-worktree-overrides.sh — gitignored, do not edit.
|
|
// Applies to Debug builds only (included from Flutter/Debug.xcconfig before
|
|
// AppOverrides.xcconfig, so a developer's app-specific overrides win).
|
|
BUNDLE_IDENTIFIER = ${ios_bundle_id}
|
|
APP_DISPLAY_NAME = Buzz (${label})
|
|
XCCONFIG
|
|
|
|
cat > "$android_props" <<PROPERTIES
|
|
# Generated by scripts/mobile-worktree-overrides.sh — gitignored, do not edit.
|
|
# Applies to the debug build type only (read by android/app/build.gradle.kts).
|
|
label=${label}
|
|
applicationIdSuffix=${android_suffix}
|
|
PROPERTIES
|
|
|
|
# The printed identifiers are the generated defaults; on iOS a developer's
|
|
# AppOverrides.xcconfig may override them per variable.
|
|
echo "📱 Worktree ${worktree_name}: label \"${label}\" (iOS default ${ios_bundle_id}, Android suffix ${android_suffix})"
|