@@ -36,13 +36,14 @@ struct Release: AsyncParsableCommand {
3636 let ( zipFileURL, checksum) = try package . zipBinary ( with: product)
3737
3838 try await updatePackage ( package , with: product, checksum: checksum)
39- try commitAndPush ( with: product)
39+ try commitAndPush ( package , with: product)
4040 try await package . makeRelease ( with: product, uploading: zipFileURL)
4141 }
4242
4343 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
4647
4748 Log . info ( " Building \( branch) at \( commitHash) " )
4849
@@ -66,17 +67,18 @@ struct Release: AsyncParsableCommand {
6667 try await package . updateManifest ( with: product, checksum: checksum)
6768 }
6869
69- func commitAndPush( with product: BuildProduct ) throws {
70+ func commitAndPush( _ package : Package , with product: BuildProduct ) throws {
7071 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) ) " )
7476
7577 guard !localOnly else {
7678 Log . info ( " Skipping push for --local-only " )
7779 return
7880 }
7981
80- try Zsh . run ( command : " git push " )
82+ try git. push ( )
8183 }
8284}
0 commit comments