~jan0sch/smederee

Showing details for patch 09fa34d4392279cbda1cfe26ebfae82375e208f8.
2025-04-20 (Sun), 2:36 PM - Jens Grassel - 09fa34d4392279cbda1cfe26ebfae82375e208f8

darcs: Workaround for os-lib loosing stderr in repair command

- use `mergeErrIntoOut` flag to not loose stderr
- use proper `Chain.fromSeq` to be able to iterate over output lines
Summary of changes
1 files modified with 9 lines added and 2 lines removed
  • modules/darcs/src/main/scala/de/smederee/darcs/DarcsCommands.scala with 9 added and 2 removed lines
diff -rN -u old-smederee/modules/darcs/src/main/scala/de/smederee/darcs/DarcsCommands.scala new-smederee/modules/darcs/src/main/scala/de/smederee/darcs/DarcsCommands.scala
--- old-smederee/modules/darcs/src/main/scala/de/smederee/darcs/DarcsCommands.scala	2025-06-20 20:33:09.136774334 +0000
+++ new-smederee/modules/darcs/src/main/scala/de/smederee/darcs/DarcsCommands.scala	2025-06-20 20:33:09.136774334 +0000
@@ -258,9 +258,16 @@
         val directory       = Paths.get(basePath.toString, repositoryName)
         val darcsOptions    = List("repair") ::: options.toList
         val externalCommand = os.proc(darcsBinary.toString, darcsOptions)
+        // TODO: Using `mergeErrIntoOut` is a workaround for stderr being empty in the error case!
         for {
-            process <- Sync[F].delay(externalCommand.call(cwd = os.Path(directory), check = false))
-        } yield DarcsCommandOutput(process.exitCode, Chain(process.out.text()), Chain(process.err.text()))
+            process <- Sync[F].delay(
+                externalCommand.call(cwd = os.Path(directory), check = false, mergeErrIntoOut = true)
+            )
+        } yield DarcsCommandOutput(
+            process.exitCode,
+            Chain.fromSeq(process.out.lines()),
+            Chain.fromSeq(process.err.lines())
+        )
     }
 
     /** Run the darcs show dependencies command on the given repository and return the output.