diff --git a/macos/Sources/Features/About/AboutView.swift b/macos/Sources/Features/About/AboutView.swift index d9a12e4dc..af6f64504 100644 --- a/macos/Sources/Features/About/AboutView.swift +++ b/macos/Sources/Features/About/AboutView.swift @@ -10,6 +10,39 @@ struct AboutView: View { private var build: String? { Bundle.main.infoDictionary?["CFBundleVersion"] as? String } private var commit: String? { Bundle.main.infoDictionary?["GhosttyCommit"] as? String } private var version: String? { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String } + + private enum VersionConfig { + case stable(version: String) + case tip(commit: String?) + case other(String) + case none + + init(version: String?) { + guard let version else { self = .none; return } + if version.range(of: #"^\d+\.\d+\.\d+$"#, options: .regularExpression) != nil { + self = .stable(version: version) + return + } + if version.range(of: #"^[0-9a-f]{7,40}$"#, options: .regularExpression) != nil { + self = .tip(commit: version) + return + } + self = .other(version) + } + + var url: URL? { + switch self { + case .stable(let version): + let slug = version.replacingOccurrences(of: ".", with: "-") + return URL(string: "https://ghostty.org/docs/install/release-notes/\(slug)") + default: + return nil + } + } + } + + private var versionConfig: VersionConfig { VersionConfig(version: version) } + private var copyright: String? { Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String } #if os(macOS) @@ -60,8 +93,15 @@ struct AboutView: View { .textSelection(.enabled) VStack(spacing: 2) { - if let version { - PropertyRow(label: "Version", text: version) + switch versionConfig { + case .stable(let version): + PropertyRow(label: "Version", text: version, url: versionConfig.url) + case .tip: + PropertyRow(label: "Version", text: "Tip Release") + case .other(let v): + PropertyRow(label: "Version", text: v) + case .none: + EmptyView() } if let build { PropertyRow(label: "Build", text: build)