Initial commit

This commit is contained in:
2023-03-10 11:07:27 -05:00
commit c4ac51a1c0
11 changed files with 358 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import ShellClient
import XCTestDynamicOverlay
public struct GitVersionClient {
private var currentVersion: (String?) throws -> String
public init(currentVersion: @escaping (String?) throws -> String) {
self.currentVersion = currentVersion
}
public func currentVersion(in gitDirectory: String? = nil) throws -> String {
try self.currentVersion(gitDirectory)
}
public mutating func override(with version: String) {
self.currentVersion = { _ in version }
}
}
extension GitVersionClient: TestDependencyKey {
public static let testValue = GitVersionClient(
currentVersion: unimplemented("\(Self.self).currentVersion", placeholder: "")
)
}
extension DependencyValues {
public var gitVersionClient: GitVersionClient {
get { self[GitVersionClient.self] }
set { self[GitVersionClient.self] = newValue }
}
}