adds nice git interface

This commit is contained in:
2026-10-30 13:21:45 +01:00
parent b9c03a7637
commit caec81e762
107 changed files with 6466 additions and 3992 deletions
+15 -13
View File
@@ -41,12 +41,18 @@ public struct GitSnapshot: Sendable, Equatable {
public var ahead: Int
/// True when a push would send something, including a branch without an upstream.
public var canPush: Bool
/// Commits the remote has that the branch does not; 0 when unknown.
public var behind: Int
/// The tracked branch, such as "origin/main"; nil without one.
public var upstream: String?
public var changes: [GitFileChange]
public init(branch: String, ahead: Int, canPush: Bool, changes: [GitFileChange]) {
public init(branch: String, ahead: Int, canPush: Bool, behind: Int = 0, upstream: String? = nil, changes: [GitFileChange]) {
self.branch = branch
self.ahead = ahead
self.canPush = canPush
self.behind = behind
self.upstream = upstream
self.changes = changes
}
}
@@ -86,6 +92,10 @@ public struct GitWorkingState: Sendable, Equatable {
public var branch: String
public var ahead: Int
public var canPush: Bool
/// Commits the remote has that the branch does not; 0 when unknown.
public var behind: Int
/// The tracked branch, such as "origin/main"; nil without one.
public var upstream: String?
public var changes: [Change]
/// Per path: HEAD vs disk. Drives the Actual view.
public var fileDiffs: [String: Diff]
@@ -97,13 +107,16 @@ public struct GitWorkingState: Sendable, Equatable {
public var isRepository: Bool
public init(
branch: String = "—", ahead: Int = 0, canPush: Bool = false, changes: [Change] = [],
branch: String = "—", ahead: Int = 0, canPush: Bool = false, behind: Int = 0, upstream: String? = nil,
changes: [Change] = [],
fileDiffs: [String: Diff] = [:], rowDiffs: [String: Diff] = [:],
stagedPaths: Set<String> = [], isRepository: Bool = false
) {
self.branch = branch
self.ahead = ahead
self.canPush = canPush
self.behind = behind
self.upstream = upstream
self.changes = changes
self.fileDiffs = fileDiffs
self.rowDiffs = rowDiffs
@@ -127,14 +140,3 @@ public struct GitWorkingState: Sendable, Equatable {
return changes.filter { !$0.staged && seen.insert($0.path).inserted }.map(\.path)
}
}
/// The outcome of a push, shown in a toast.
public struct PushResult: Sendable, Equatable {
public var ok: Bool
public var message: String
public init(ok: Bool, message: String) {
self.ok = ok
self.message = message
}
}