Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parent commits to build details #312

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions FreeAPS/Sources/Helpers/BuildDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ class BuildDetails {
dict["com-trio-build-date"] as? String
}

var branchAndSha: String {
var branch: String {
let branch = dict["com-trio-branch"] as? String ?? "Unknown"
return "\(branch)"
}

var sha: String {
let sha = dict["com-trio-commit-sha"] as? String ?? "Unknown"
return "\(branch) \(sha)"
return "\(sha)"
}

// Determine if the build is from TestFlight
Expand Down
5 changes: 4 additions & 1 deletion FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension Settings {
private(set) var buildNumber = ""
private(set) var versionNumber = ""
private(set) var branch = ""
private(set) var sha = ""
private(set) var copyrightNotice = ""

override func subscribe() {
Expand All @@ -31,7 +32,9 @@ extension Settings {

versionNumber = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"

branch = BuildDetails.default.branchAndSha
branch = BuildDetails.default.branch

sha = BuildDetails.default.sha

copyrightNotice = Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String ?? ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class SettingsRootViewModel: ObservableObject {
let buildDetails = BuildDetails.default
let versionNumber = Bundle.main.releaseVersionNumber ?? "Unknown"
let buildNumber = Bundle.main.buildVersionNumber ?? "Unknown"
let branch = buildDetails.branchAndSha
let branch = buildDetails.branch
let sha = buildDetails.sha

let headerBase = "Trio v\(versionNumber) (\(buildNumber))\nBranch: \(branch)"
let headerBase = "Trio v\(versionNumber) (\(buildNumber))\nBranch: \(branch)\nCommit: \(sha)"

if let expirationDate = buildDetails.calculateExpirationDate() {
let formattedDate = DateFormatter.localizedString(from: expirationDate, dateStyle: .medium, timeStyle: .none)
Expand Down
5 changes: 3 additions & 2 deletions scripts/capture-build-details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ else
# Attempt to retrieve the current tag
git_tag=$(git describe --tags --exact-match 2>/dev/null || echo "")

# Retrieve the current SHA of the latest commit
git_commit_sha=$(git log -1 --format="%h" --abbrev=7)
# Retrieve SHA of the latest commit and parent commits
git_commit_sha=$(git log -1 --format="%h %p" --abbrev=7 | awk '{ printf "%s", $1; for(i=2;i<=NF;i++) printf " Parent%d: %s", i-1, $i; printf "\n"; }'
)

# Determine the branch or tag information
git_branch_or_tag="${git_branch:-${git_tag}}"
Expand Down