Build Number Hash Alignment
Nucleic-Session: F8E9CC32-59CC-4022-B42C-0B0694C57F42 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -32,11 +32,16 @@ enum BuildChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build identity for the running app: which channel it came from and its build label.
|
/// Build identity for the running app: which channel it came from and its build label.
|
||||||
/// The Mac embeds a git commit via a prebuild plugin; the iOS build number is derived from
|
/// Both platforms show the short git commit: the Mac embeds it via a prebuild plugin, and
|
||||||
/// `git rev-list --count` at archive time (scripts/ios-release.sh), so `CFBundleVersion`
|
/// here the NucleicRemote target's "Stamp git commit into Info.plist" build phase writes
|
||||||
/// plays the same role here.
|
/// `git rev-parse --short HEAD` into the `NucleicCommit` Info.plist key. Falls back to
|
||||||
|
/// `CFBundleVersion` (the `git rev-list --count` build number from scripts/ios-release.sh)
|
||||||
|
/// when git isn't available.
|
||||||
struct BuildInfo {
|
struct BuildInfo {
|
||||||
let channel: BuildChannel
|
let channel: BuildChannel
|
||||||
|
/// The short git commit the binary was built from (e.g. "a1b2c3d", "+" suffix when the
|
||||||
|
/// tree was dirty) — matching the Mac's banner. Falls back to `CFBundleVersion` / "local"
|
||||||
|
/// if the build phase couldn't resolve a hash.
|
||||||
let buildLabel: String
|
let buildLabel: String
|
||||||
/// `CFBundleShortVersionString` when present, else `nil`.
|
/// `CFBundleShortVersionString` when present, else `nil`.
|
||||||
let version: String?
|
let version: String?
|
||||||
@@ -47,7 +52,13 @@ struct BuildInfo {
|
|||||||
init() {
|
init() {
|
||||||
let info = Bundle.main.infoDictionary
|
let info = Bundle.main.infoDictionary
|
||||||
version = info?["CFBundleShortVersionString"] as? String
|
version = info?["CFBundleShortVersionString"] as? String
|
||||||
buildLabel = (info?["CFBundleVersion"] as? String) ?? "local"
|
// Prefer the stamped git commit (mirrors the Mac's GitCommit.hash); an empty or
|
||||||
|
// "unknown" value means git wasn't available at build time, so fall back to the
|
||||||
|
// bundle build number.
|
||||||
|
let commit = info?["NucleicCommit"] as? String
|
||||||
|
buildLabel = commit.flatMap { $0.isEmpty || $0 == "unknown" ? nil : $0 }
|
||||||
|
?? (info?["CFBundleVersion"] as? String)
|
||||||
|
?? "local"
|
||||||
channel = Self.detectChannel(stamped: info?["NucleicChannel"] as? String)
|
channel = Self.detectChannel(stamped: info?["NucleicChannel"] as? String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user