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

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

mercurial