File tree 2 files changed +24
-2
lines changed 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public final class Git: Shell {
18
18
case status( short: Bool = false )
19
19
case commit( message: String , Bool = false )
20
20
case config( name: String , value: String )
21
- case clone( url: String )
21
+ case clone( url: String , dirName : String ? = nil )
22
22
case checkout( branch: String , create: Bool = false )
23
23
case log( numberOfCommits: Int ? = nil , options: [ String ] ? = nil , revisions: String ? = nil )
24
24
case push( remote: String ? = nil , branch: String ? = nil )
@@ -57,8 +57,11 @@ public final class Git: Shell {
57
57
if allowEmpty {
58
58
params. append ( " --allow-empty " )
59
59
}
60
- case . clone( let url) :
60
+ case . clone( let url, let dirname ) :
61
61
params = [ Command . clone. rawValue, url]
62
+ if let dirName = dirname {
63
+ params. append ( dirName)
64
+ }
62
65
case . checkout( let branch, let create) :
63
66
params = [ Command . checkout. rawValue]
64
67
if create {
Original file line number Diff line number Diff line change @@ -103,6 +103,25 @@ final class GitKitTests: XCTestCase {
103
103
try self . clean ( path: path)
104
104
self . assert ( type: " output " , result: statusOutput, expected: expectation)
105
105
}
106
+
107
+ func testCloneWithDirectory( ) throws {
108
+ let path = self . currentPath ( )
109
+
110
+ let expectation = """
111
+ On branch master
112
+ Your branch is up to date with 'origin/master'.
113
+
114
+ nothing to commit, working tree clean
115
+ """
116
+
117
+ try self . clean ( path: path)
118
+ let git = Git ( path: path)
119
+
120
+ try git
. run ( . clone
( url
: " [email protected] :binarybirds/shell-kit" , dirName
: " MyCustomDirectory " ) )
121
+ let statusOutput = try git. run ( " cd \( path) /MyCustomDirectory && git status " )
122
+ try self . clean ( path: path)
123
+ self . assert ( type: " output " , result: statusOutput, expected: expectation)
124
+ }
106
125
107
126
#if os(macOS)
108
127
func testAsyncRun( ) throws {
You can’t perform that action at this time.
0 commit comments