src/main/kotlin/de/uapcore/lightpit/vcs/VcsConnector.kt

changeset 281
c15b9555ecf3
parent 280
12b898531d1a
     1.1 --- a/src/main/kotlin/de/uapcore/lightpit/vcs/VcsConnector.kt	Tue Jul 18 18:05:49 2023 +0200
     1.2 +++ b/src/main/kotlin/de/uapcore/lightpit/vcs/VcsConnector.kt	Sat Jul 22 11:32:27 2023 +0200
     1.3 @@ -7,13 +7,17 @@
     1.4      /**
     1.5       * Invokes the VCS binary with the given [args] and returns the output on stdout.
     1.6       */
     1.7 -    protected fun invokeCommand(workingDir: Path, vararg args : String): VcsConnectorResult<String> {
     1.8 +    protected fun invokeCommand(
     1.9 +        vararg args: String,
    1.10 +        workingDir: Path = Path.of("."),
    1.11 +        timeout: Long = 30L
    1.12 +    ): VcsConnectorResult<String> {
    1.13          return try {
    1.14              val command = mutableListOf(path)
    1.15              command.addAll(args)
    1.16              val process = ProcessBuilder(command).directory(workingDir.toFile()).start()
    1.17              val stdout = String(process.inputStream.readAllBytes(), Charsets.UTF_8)
    1.18 -            if (process.waitFor(30, TimeUnit.SECONDS)) {
    1.19 +            if (process.waitFor(timeout, TimeUnit.SECONDS)) {
    1.20                  if (process.exitValue() == 0) {
    1.21                      VcsConnectorResult.Success(stdout)
    1.22                  } else {

mercurial