Skip to content
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
14 changes: 14 additions & 0 deletions macos/Sources/Lithe/Core/Rust/RustCoreBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,18 @@ struct RustCoreBridge: Sendable {
let conflictedPaths: [String]
}

struct TagDeletion: Decodable, Sendable {
let name: String
let deletedTarget: String
let kind: GitTagKind
let message: String?
}

struct BranchDeletion: Decodable, Sendable {
let name: String
let deletedTarget: String
}

let arguments: [String]?
let output: String
let stdout: String?
Expand All @@ -826,6 +838,8 @@ struct RustCoreBridge: Sendable {
let invocations: [Invocation]?
let operationError: OperationError?
let stashRestore: StashRestore?
let tagDeletion: TagDeletion?
let branchDeletion: BranchDeletion?
}

struct GitDiffPayload: Decodable, Sendable {
Expand Down
33 changes: 33 additions & 0 deletions macos/Sources/Lithe/Core/Rust/RustGitOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ struct RustGitOperations: GitOperations, Sendable {
stashReference: $0.stashReference,
conflictedPaths: $0.conflictedPaths
)
},
tagDeletion: response.tagDeletion.map {
GitTagDeletion(
name: $0.name,
deletedTarget: $0.deletedTarget,
kind: $0.kind,
message: $0.message
)
},
branchDeletion: response.branchDeletion.map {
GitBranchDeletion(
name: $0.name,
deletedTarget: $0.deletedTarget
)
}
)
}
Expand Down Expand Up @@ -310,6 +324,25 @@ struct RustGitOperations: GitOperations, Sendable {
write(at: rootURL, operation: "stageAll")
}

func createTag(
named name: String,
at revision: String,
message: String?,
rootURL: URL
) -> GitProcessResult? {
write(
at: rootURL,
operation: "createTag",
revision: revision,
name: name,
message: message
)
}

func deleteTag(named name: String, rootURL: URL) -> GitProcessResult? {
write(at: rootURL, operation: "deleteTag", name: name)
}

func snapshot(at rootURL: URL) -> GitSnapshot? {
core.gitStatus(at: rootURL)?.makeSnapshot(at: rootURL)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ extension AppModel {
var requestedStashReference: String? {
gitFeatureIfActive?.requestedStashReference
}
var recentlyDeletedTag: GitTagDeletion? {
gitFeatureIfActive?.recentlyDeletedTag
}
var recentlyDeletedBranch: GitBranchDeletion? {
gitFeatureIfActive?.recentlyDeletedBranch
}
var isCommitting: Bool { gitFeatureIfActive?.isCommitting ?? false }
var gitBlameLines: [URL: [GitBlameLine]] { gitFeatureIfActive?.gitBlameLines ?? [:] }
var gitReferences: [GitReference] { gitFeatureIfActive?.gitReferences ?? [] }
Expand Down
31 changes: 31 additions & 0 deletions macos/Sources/Lithe/Models/AppModel/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,37 @@ final class AppModel: ObservableObject, Identifiable {
await gitFeature.deleteBranch(reference)
}

func restoreRecentlyDeletedBranch() async {
guard let gitFeature = await activateGitModule() else { return }
await gitFeature.restoreRecentlyDeletedBranch()
}

func dismissDeletedBranchBanner() {
gitFeatureIfActive?.dismissDeletedBranchBanner()
}

/// Returns nil on success, otherwise the error message a tag dialog
/// should show where the user typed.
@discardableResult
func createTag(at commit: GitCommit, name: String, message: String) async -> String? {
guard let gitFeature = await activateGitModule() else { return "No Git repository is open" }
return await gitFeature.createTag(at: commit, name: name, message: message)
}

func deleteTag(_ reference: GitReference) async {
guard let gitFeature = await activateGitModule() else { return }
await gitFeature.deleteTag(reference)
}

func restoreRecentlyDeletedTag() async {
guard let gitFeature = await activateGitModule() else { return }
await gitFeature.restoreRecentlyDeletedTag()
}

func dismissDeletedTagBanner() {
gitFeatureIfActive?.dismissDeletedTagBanner()
}

func mergeBranch(_ reference: GitReference) async {
guard let gitFeature = await activateGitModule() else { return }
await gitFeature.mergeBranch(reference)
Expand Down
2 changes: 2 additions & 0 deletions macos/Sources/Lithe/Views/Git/GitGraphView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct GitGraphRowActions {
let onCherryPick: (GitCommit) -> Void
let onRevert: (GitCommit) -> Void
let onReset: (GitCommit) -> Void
let onCreateTag: (GitCommit) -> Void
}

struct GitGraphView: View {
Expand Down Expand Up @@ -136,6 +137,7 @@ private struct GitGraphRowView: View, Equatable {
NSPasteboard.general.setString(row.commit.shortHash, forType: .string)
}
Divider()
Button("New Tag…") { actions.onCreateTag(row.commit) }
Button("Cherry-pick Commit…") { actions.onCherryPick(row.commit) }
Button("Revert Commit…") { actions.onRevert(row.commit) }
Button("Reset Current Branch to Here…") { actions.onReset(row.commit) }
Expand Down
Loading
Loading