@@ -36,13 +36,14 @@ struct Release: AsyncParsableCommand {
36
36
let ( zipFileURL, checksum) = try package . zipBinary ( with: product)
37
37
38
38
try await updatePackage ( package , with: product, checksum: checksum)
39
- try commitAndPush ( with: product)
39
+ try commitAndPush ( package , with: product)
40
40
try await package . makeRelease ( with: product, uploading: zipFileURL)
41
41
}
42
42
43
43
mutating func build( ) throws -> BuildProduct {
44
- let commitHash = try Zsh . run ( command: " git rev-parse HEAD " , directory: buildDirectory) !. trimmingCharacters ( in: . whitespacesAndNewlines)
45
- let branch = try Zsh . run ( command: " git rev-parse --abbrev-ref HEAD " , directory: buildDirectory) !. trimmingCharacters ( in: . whitespacesAndNewlines)
44
+ let git = Git ( directory: buildDirectory)
45
+ let commitHash = try git. commitHash
46
+ let branch = try git. branchName
46
47
47
48
Log . info ( " Building \( branch) at \( commitHash) " )
48
49
@@ -66,17 +67,18 @@ struct Release: AsyncParsableCommand {
66
67
try await package . updateManifest ( with: product, checksum: checksum)
67
68
}
68
69
69
- func commitAndPush( with product: BuildProduct ) throws {
70
+ func commitAndPush( _ package : Package , with product: BuildProduct ) throws {
70
71
Log . info ( " Pushing changes " )
71
- try Zsh . run ( command: " git add Package.swift " )
72
- try Zsh . run ( command: " git add Sources " )
73
- try Zsh . run ( command: " git commit -m 'Bump to version \( version) ( \( product. sourceRepo. name) / \( product. branch) \( product. commitHash) )' " )
72
+
73
+ let git = Git ( directory: package . directory)
74
+ try git. add ( files: " Package.swift " , " Sources " )
75
+ try git. commit ( message: " Bump to version \( version) ( \( product. sourceRepo. name) / \( product. branch) \( product. commitHash) ) " )
74
76
75
77
guard !localOnly else {
76
78
Log . info ( " Skipping push for --local-only " )
77
79
return
78
80
}
79
81
80
- try Zsh . run ( command : " git push " )
82
+ try git. push ( )
81
83
}
82
84
}
0 commit comments