Skip to content

Commit ebb0ae7

Browse files
committed
Use Git tool
1 parent 1436e7f commit ebb0ae7

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Tools/Release/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let package = Package(
99
products: [.executable(name: "release", targets: ["Release"])],
1010
dependencies: [
1111
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
12-
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "c8e3448595363a3948f6260053fc78d3accb2ebc")
12+
.package(url: "https://github.com/element-hq/swift-command-line-tools.git", revision: "b30768277abb107f5d514489cae0145ddaac9334")
1313
// .package(path: "../../../swift-command-line-tools")
1414
],
1515
targets: [

Tools/Release/Sources/Release.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)