From 2d99e0191c617f8812fba6403f307e65058e2d60 Mon Sep 17 00:00:00 2001 From: Austin Condiff Date: Thu, 8 Aug 2024 12:40:59 -0500 Subject: [PATCH 1/2] Enabled git push force and tags. --- .../SourceControl/Client/GitClient+Push.swift | 14 +++++++++++++- .../SourceControlManager+GitClient.swift | 10 ++++++++-- .../Views/SourceControlPushView.swift | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CodeEdit/Features/SourceControl/Client/GitClient+Push.swift b/CodeEdit/Features/SourceControl/Client/GitClient+Push.swift index aa0f08e852..4295c075ae 100644 --- a/CodeEdit/Features/SourceControl/Client/GitClient+Push.swift +++ b/CodeEdit/Features/SourceControl/Client/GitClient+Push.swift @@ -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)" } diff --git a/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift b/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift index 745178f8a4..ed3efc567d 100644 --- a/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift +++ b/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift @@ -288,10 +288,16 @@ 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() diff --git a/CodeEdit/Features/SourceControl/Views/SourceControlPushView.swift b/CodeEdit/Features/SourceControl/Views/SourceControlPushView.swift index 2fa8f797a4..8b280cb806 100644 --- a/CodeEdit/Features/SourceControl/Views/SourceControlPushView.swift +++ b/CodeEdit/Features/SourceControl/Views/SourceControlPushView.swift @@ -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() From 7eef7bf144cd9985b41eb8bde973bf7da3024c51 Mon Sep 17 00:00:00 2001 From: Austin Condiff Date: Thu, 8 Aug 2024 12:45:45 -0500 Subject: [PATCH 2/2] Fixed SwiftLint error --- .../SourceControl/SourceControlManager+GitClient.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift b/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift index ed3efc567d..0c6b6d990b 100644 --- a/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift +++ b/CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift @@ -297,7 +297,13 @@ extension SourceControlManager { ) async throws { guard currentBranch != nil else { return } - try await gitClient.pushToRemote(remote: remote, branch: branch, setUpstream: setUpstream, force: force, tags: tags) + try await gitClient.pushToRemote( + remote: remote, + branch: branch, + setUpstream: setUpstream, + force: force, + tags: tags + ) await refreshCurrentBranch() await self.refreshNumberOfUnsyncedCommits()