@@ -25,22 +25,22 @@ public class SwiftPMDependencyProject {
25
25
/// The directory in which the repository lives.
26
26
public let packageDirectory : URL
27
27
28
- private func runCommand ( _ toolName : String , _ arguments: [ String ] , workingDirectory: URL ) async throws {
28
+ private func runGitCommand ( _ arguments: [ String ] , workingDirectory: URL ) async throws {
29
29
enum Error : Swift . Error {
30
- case cannotFindTool ( toolName : String )
30
+ case cannotFindGit
31
31
case processedTerminatedWithNonZeroExitCode( ProcessResult )
32
32
}
33
- guard let toolUrl = findTool ( name: toolName ) else {
33
+ guard let toolUrl = findTool ( name: " git " ) else {
34
34
if ProcessEnv . block [ " SWIFTCI_USE_LOCAL_DEPS " ] == nil {
35
35
// Never skip the test in CI, similar to what SkipUnless does.
36
- throw XCTSkip ( " \( toolName ) cannot be found " )
36
+ throw XCTSkip ( " git cannot be found" )
37
37
}
38
- throw Error . cannotFindTool ( toolName : toolName )
38
+ throw Error . cannotFindGit
39
39
}
40
- print ( [ toolUrl. path] + arguments)
40
+ // We can't use `workingDirectory` because Amazon Linux doesn't support working directories (or at least
41
+ // TSCBasic.Process doesn't support working directories on Amazon Linux)
41
42
let process = TSCBasic . Process (
42
- arguments: [ toolUrl. path] + arguments,
43
- workingDirectory: try AbsolutePath ( validating: workingDirectory. path)
43
+ arguments: [ toolUrl. path, " -C " , workingDirectory. path] + arguments
44
44
)
45
45
try process. launch ( )
46
46
let processResult = try await process. waitUntilExit ( )
@@ -80,18 +80,16 @@ public class SwiftPMDependencyProject {
80
80
try contents. write ( to: fileURL, atomically: true , encoding: . utf8)
81
81
}
82
82
83
- try await runCommand ( " git " , [ " init " ] , workingDirectory: packageDirectory)
84
- try await runCommand (
85
- " git " ,
83
+ try await runGitCommand ( [ " init " ] , workingDirectory: packageDirectory)
84
+ try await runGitCommand (
86
85
[ " add " ] + files. keys. map { $0. url ( relativeTo: packageDirectory) . path } ,
87
86
workingDirectory: packageDirectory
88
87
)
89
- try await runCommand (
90
- " git " ,
88
+ try await runGitCommand (
91
89
[ " -c " , " user.name=Dummy " , " -c " , " [email protected] " , " commit " , " -m " , " Initial commit " ] ,
92
90
workingDirectory: packageDirectory
93
91
)
94
- try await runCommand ( " git " , [ " tag " , " 1.0.0 " ] , workingDirectory: packageDirectory)
92
+ try await runGitCommand ( [ " tag " , " 1.0.0 " ] , workingDirectory: packageDirectory)
95
93
}
96
94
97
95
deinit {
0 commit comments