improves the git feature by adding a conflict status
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
/// The status letter a git row shows. Copies and untracked files read as `A`, conflicts as `M`.
|
||||
/// The status letter a git row shows. Copies and untracked files read as `A`, conflicts as `U`.
|
||||
public enum GitStatus: String, Codable, Sendable, CaseIterable {
|
||||
case added = "A"
|
||||
case modified = "M"
|
||||
|
||||
@@ -131,14 +131,14 @@ public enum Porcelain {
|
||||
}
|
||||
}
|
||||
|
||||
/// A merge conflict. Neither half can be staged on its own, so it stays one row.
|
||||
/// A merge conflict. Neither half can be staged on its own, so it stays one unstaged `U` row.
|
||||
public static func isConflict(index: Character, working: Character) -> Bool {
|
||||
index == "U" || working == "U" || (index == "A" && working == "A") || (index == "D" && working == "D")
|
||||
}
|
||||
|
||||
/// Splits an XY pair into rows: "MM" is a staged row plus an unstaged row, never one folded row.
|
||||
public static func classify(index: Character, working: Character) -> [GitRowSpec] {
|
||||
if isConflict(index: index, working: working) { return [GitRowSpec(status: .modified, staged: true)] }
|
||||
if isConflict(index: index, working: working) { return [GitRowSpec(status: .unmerged, staged: false)] }
|
||||
var rows: [GitRowSpec] = []
|
||||
if index != " " && index != "?" { rows.append(GitRowSpec(status: status(for: index), staged: true)) }
|
||||
if working != " " { rows.append(GitRowSpec(status: status(for: working), staged: false)) }
|
||||
|
||||
Reference in New Issue
Block a user