Skip to content

Commit

Permalink
Enabled git push force and tags options (#1846)
Browse files Browse the repository at this point in the history
* Enabled git push force and tags.
  • Loading branch information
austincondiff authored Aug 14, 2024
1 parent a231637 commit be21f9d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
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

0 comments on commit be21f9d

Please sign in to comment.