Skip to content

Commit a360428

Browse files
author
Andrew McKnight
committed
add parameter to allow specifying a remote tracking branch
1 parent 92cb559 commit a360428

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/GitKit/Git.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ public final class Git: Shell {
1919
case commit(message: String, Bool = false)
2020
case config(name: String, value: String)
2121
case clone(url: String)
22-
case checkout(branch: String, create: Bool = false)
22+
23+
/// - parameter branch the name of the branch to checkout
24+
/// - parameter create whether to create a new branch or checkout an existing one
25+
/// - parameter tracking when creating a new branch, the name of the remote branch it should track
26+
case checkout(branch: String, create: Bool = false, tracking: String? = nil)
27+
2328
case log(numberOfCommits: Int? = nil, options: [String]? = nil, revisions: String? = nil)
2429
case push(remote: String? = nil, branch: String? = nil)
2530
case pull(remote: String? = nil, branch: String? = nil, rebase: Bool = false)
@@ -59,12 +64,15 @@ public final class Git: Shell {
5964
}
6065
case .clone(let url):
6166
params = [Command.clone.rawValue, url]
62-
case .checkout(let branch, let create):
67+
case .checkout(let branch, let create, let tracking):
6368
params = [Command.checkout.rawValue]
6469
if create {
6570
params.append("-b")
6671
}
6772
params.append(branch)
73+
if let tracking {
74+
params.append(tracking)
75+
}
6876
case .log(let numberOfCommits, let options, let revisions):
6977
params = [Command.log.rawValue]
7078
if let numberOfCommits = numberOfCommits {

0 commit comments

Comments
 (0)