Add Check for clean git status
This commit is contained in:
parent
66e003d221
commit
5dc4ad12bd
|
@ -11,6 +11,13 @@ protocol ScriptLaunching {
|
|||
func launchScript(withContent content: String, version: String?) throws -> String
|
||||
}
|
||||
|
||||
extension ScriptLaunching {
|
||||
@discardableResult
|
||||
func launchScript(withContent content: String) throws -> String {
|
||||
return try launchScript(withContent: content, version: nil)
|
||||
}
|
||||
}
|
||||
|
||||
struct ScriptLauncher: ScriptLaunching {
|
||||
func launchScript(withContent content: String, version: String?) throws -> String {
|
||||
var runnableContent: String
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import Foundation
|
||||
|
||||
struct CleanGitStatusCheck: PreReleaseCheck {
|
||||
let launcher: ScriptLaunching
|
||||
|
||||
func check() -> Bool {
|
||||
let result = try? launcher.launchScript(withContent: "git diff --name-only", version: nil)
|
||||
|
||||
return result?.isEmpty ?? true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
protocol PreReleaseCheck {
|
||||
func check() -> Bool
|
||||
}
|
|
@ -1,7 +1,13 @@
|
|||
import Foundation
|
||||
import Logger
|
||||
|
||||
public class StepsParser {
|
||||
public enum StepsParser {
|
||||
enum CodingKeys: String {
|
||||
case steps
|
||||
case before
|
||||
case after
|
||||
}
|
||||
|
||||
private static let defaultSteps: [Any] = [
|
||||
Step.hideDependencies.rawValue,
|
||||
Step.gitAdd.rawValue,
|
||||
|
@ -13,12 +19,6 @@ public class StepsParser {
|
|||
Step.push.rawValue,
|
||||
]
|
||||
|
||||
enum CodingKeys: String {
|
||||
case steps
|
||||
case before
|
||||
case after
|
||||
}
|
||||
|
||||
public static func parseSteps(fromDictionary dictionary: [String: Any], logger: Logger) -> [StepExecutor] {
|
||||
guard let stepsArray = steps(fromDictionary: dictionary) else {
|
||||
logger.logError("Invalid steps")
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import Nimble
|
||||
@testable import RocketLib
|
||||
import TestSpy
|
||||
import XCTest
|
||||
|
||||
final class CleanGitStatusCheckTests: XCTestCase {
|
||||
func testReturnsTrueWhenThereIsAreNoModifiedFiles() {
|
||||
let scriptLauncher = SpyScriptLauncher()
|
||||
scriptLauncher.result = ""
|
||||
let check = CleanGitStatusCheck(launcher: scriptLauncher)
|
||||
|
||||
let result = check.check()
|
||||
|
||||
expect(result).to(beTrue())
|
||||
expect(scriptLauncher).to(haveReceived(.launchScript(content: "git diff --name-only", version: nil)))
|
||||
}
|
||||
|
||||
func testReturnsFalseWhenThereIsAreModifiedFiles() {
|
||||
let scriptLauncher = SpyScriptLauncher()
|
||||
scriptLauncher.result = "/Franco/Test.swift"
|
||||
let check = CleanGitStatusCheck(launcher: scriptLauncher)
|
||||
|
||||
let result = check.check()
|
||||
|
||||
expect(result).to(beFalse())
|
||||
expect(scriptLauncher).to(haveReceived(.launchScript(content: "git diff --name-only", version: nil)))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue