xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XCLIUtils / CommandVersion.swift
CommandVersion.swift19 lines · 560 BRaw
| 1 | public struct CommandVersion: Sendable, Hashable { |
| 2 | public var version: String |
| 3 | public var hasUncommittedChanges: Bool |
| 4 | |
| 5 | public init(version: String, hasUncommittedChanges: Bool) { |
| 6 | self.version = version |
| 7 | self.hasUncommittedChanges = hasUncommittedChanges |
| 8 | } |
| 9 | |
| 10 | public static var unversioned: Self { |
| 11 | .init(version: "unversioned", hasUncommittedChanges: true) |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | extension CommandVersion: CustomStringConvertible { |
| 16 | public var description: String { |
| 17 | version + (hasUncommittedChanges ? "-dirty" : "") |
| 18 | } |
| 19 | } |