Skip to content
Merged
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: 13 additions & 1 deletion CodeEdit/Features/SourceControl/Client/GitClient+Push.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ import Foundation

extension GitClient {
/// Push changes to remote
func pushToRemote(remote: String? = nil, branch: String? = nil, setUpstream: Bool? = false ) async throws {
func pushToRemote(
remote: String? = nil,
branch: String? = nil,
setUpstream: Bool? = false,
force: Bool? = false,
tags: Bool? = false
) async throws {
var command = "push"
if let remote, let branch {
if setUpstream == true {
command += " --set-upstream"
}
if force == true {
command += " --force"
}
if tags == true {
command += " --tags"
}
command += " \(remote) \(branch)"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,22 @@ extension SourceControlManager {
}

/// Push changes to remote
func push(remote: String? = nil, branch: String? = nil, setUpstream: Bool = false) async throws {
func push(
remote: String? = nil,
branch: String? = nil,
setUpstream: Bool = false,
force: Bool = false,
tags: Bool = false
) async throws {
guard currentBranch != nil else { return }

try await gitClient.pushToRemote(remote: remote, branch: branch, setUpstream: setUpstream)
try await gitClient.pushToRemote(
remote: remote,
branch: branch,
setUpstream: setUpstream,
force: force,
tags: tags
)

await refreshCurrentBranch()
await self.refreshNumberOfUnsyncedCommits()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ struct SourceControlPushView: View {
try await sourceControlManager.push(
remote: sourceControlManager.operationRemote?.name ?? nil,
branch: sourceControlManager.operationBranch?.name ?? nil,
setUpstream: sourceControlManager.currentBranch?.upstream == nil
setUpstream: sourceControlManager.currentBranch?.upstream == nil,
force: sourceControlManager.operationForce,
tags: sourceControlManager.operationIncludeTags
)
self.loading = false
dismiss()
Expand Down