Skip to content

Commit be21f9d

Browse files
Enabled git push force and tags options (#1846)
* Enabled git push force and tags.
1 parent a231637 commit be21f9d

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

CodeEdit/Features/SourceControl/Client/GitClient+Push.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@ import Foundation
99

1010
extension GitClient {
1111
/// Push changes to remote
12-
func pushToRemote(remote: String? = nil, branch: String? = nil, setUpstream: Bool? = false ) async throws {
12+
func pushToRemote(
13+
remote: String? = nil,
14+
branch: String? = nil,
15+
setUpstream: Bool? = false,
16+
force: Bool? = false,
17+
tags: Bool? = false
18+
) async throws {
1319
var command = "push"
1420
if let remote, let branch {
1521
if setUpstream == true {
1622
command += " --set-upstream"
1723
}
24+
if force == true {
25+
command += " --force"
26+
}
27+
if tags == true {
28+
command += " --tags"
29+
}
1830
command += " \(remote) \(branch)"
1931
}
2032

CodeEdit/Features/SourceControl/SourceControlManager+GitClient.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,22 @@ extension SourceControlManager {
288288
}
289289

290290
/// Push changes to remote
291-
func push(remote: String? = nil, branch: String? = nil, setUpstream: Bool = false) async throws {
291+
func push(
292+
remote: String? = nil,
293+
branch: String? = nil,
294+
setUpstream: Bool = false,
295+
force: Bool = false,
296+
tags: Bool = false
297+
) async throws {
292298
guard currentBranch != nil else { return }
293299

294-
try await gitClient.pushToRemote(remote: remote, branch: branch, setUpstream: setUpstream)
300+
try await gitClient.pushToRemote(
301+
remote: remote,
302+
branch: branch,
303+
setUpstream: setUpstream,
304+
force: force,
305+
tags: tags
306+
)
295307

296308
await refreshCurrentBranch()
297309
await self.refreshNumberOfUnsyncedCommits()

CodeEdit/Features/SourceControl/Views/SourceControlPushView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ struct SourceControlPushView: View {
7575
try await sourceControlManager.push(
7676
remote: sourceControlManager.operationRemote?.name ?? nil,
7777
branch: sourceControlManager.operationBranch?.name ?? nil,
78-
setUpstream: sourceControlManager.currentBranch?.upstream == nil
78+
setUpstream: sourceControlManager.currentBranch?.upstream == nil,
79+
force: sourceControlManager.operationForce,
80+
tags: sourceControlManager.operationIncludeTags
7981
)
8082
self.loading = false
8183
dismiss()

0 commit comments

Comments
 (0)