~jan0sch/smederee
Showing details for patch b4e338257dd75eeec7dc3a55469f41f0c9081ca4.
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala 2025-02-02 06:54:30.859470922 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala 2025-02-02 06:54:30.859470922 +0000 @@ -39,11 +39,11 @@ abstract class DarcsSshCommand extends Command with ServerSessionAware { private val log = LoggerFactory.getLogger(classOf[DarcsSshCommand]) - protected var session: ServerSession = null - protected var stdin: InputStream = null - protected var stdout: OutputStream = null - protected var stderr: OutputStream = null - protected var callback: ExitCallback = null + @volatile protected var session: ServerSession = null + @volatile protected var stdin: InputStream = null + @volatile protected var stdout: OutputStream = null + @volatile protected var stderr: OutputStream = null + @volatile protected var callback: ExitCallback = null override def destroy(channel: ChannelSession): Unit = () override def setErrorStream(errorStream: OutputStream): Unit = this.stderr = errorStream @@ -63,18 +63,26 @@ * The username of the owner of the requested repository. * @param repository * The name of the vcs repository. + * @param useDebugFlag + * A flag indicating if we should use the `--debug` flag. */ -final class DarcsApply(darcsConfiguration: DarcsConfiguration, owner: Username, repository: VcsRepositoryName) - extends DarcsSshCommand { +final class DarcsApply( + darcsConfiguration: DarcsConfiguration, + owner: Username, + repository: VcsRepositoryName, + useDebugFlag: Boolean +) extends DarcsSshCommand { private val log = LoggerFactory.getLogger(classOf[DarcsApply]) override def start(channel: ChannelSession, env: Environment): Unit = { log.debug(s"DarcsApply for $owner/$repository") val repoDir = Paths.get(owner.toString, repository.toString) - val cmd = os.proc( - darcsConfiguration.executable.toString, - List("apply", "--all", "--repodir", repoDir.toString) - ) + val options = + if (useDebugFlag) + List("apply", "--all", "--debug", "--repodir", repoDir.toString) + else + List("apply", "--all", "--repodir", repoDir.toString) + val cmd = os.proc(darcsConfiguration.executable.toString, options) cmd.spawn( cwd = os.Path(darcsConfiguration.repositoriesDirectory.toPath), stdin = os.ProcessInput.makeSourceInput(this.stdin), @@ -131,9 +139,25 @@ log.debug(s"Requested SSH command: $command") command match { - case DarcsSshCommandFactory.FilterDarcsApplyCommand("apply", _, _, "--repodir", owner, repository) => + case DarcsSshCommandFactory.FilterDarcsApplyCommand( + "apply", + _, + _, + _, + debugFlag, + "--repodir", + owner, + repository + ) => (SshUsername.from(owner), VcsRepositoryName.from(repository)) - .mapN((owner, repository) => new DarcsApply(darcsConfiguration, owner.toUsername, repository)) + .mapN((owner, repository) => + new DarcsApply( + darcsConfiguration, + owner.toUsername, + repository, + debugFlag === "--debug" + ) + ) .getOrElse(new UnknownCommand(command)) case DarcsSshCommandFactory.FilterDarcsTransferModeCommand( "transfer-mode", @@ -143,7 +167,8 @@ ) => (SshUsername.from(owner), VcsRepositoryName.from(repository)) .mapN((owner, repository) => - new DarcsTransferMode(darcsConfiguration, owner.toUsername, repository) + // new DarcsTransferMode(darcsConfiguration, owner.toUsername, repository) + new UnknownCommand(command) // FIXME Make transfer-mode work (stalls currently). ) .getOrElse(new UnknownCommand(command)) case DarcsSshCommandFactory.FilterScpCommand("-f", _, "--", path) => @@ -174,7 +199,7 @@ object DarcsSshCommandFactory { // A regular expression which should match on our allowed darcs commands and their arguments. val FilterDarcsApplyCommand: Regex = - "^darcs (apply) ((--all)\\s)?\\s*(--repodir) '([a-z][a-z0-9]{1,31})/([a-zA-Z0-9][a-zA-Z0-9\\-_]{1,63})'$".r + "^darcs (apply) ((--all)\\s)?((--debug)\\s)?\\s*(--repodir) '([a-z][a-z0-9]{1,31})/([a-zA-Z0-9][a-zA-Z0-9\\-_]{1,63})'$".r val FilterDarcsTransferModeCommand: Regex = "^darcs (transfer-mode) (--repodir) ([a-z][a-z0-9]{1,31})/([a-zA-Z0-9][a-zA-Z0-9\\-_]{1,63})/?$".r // After the initial transfer-mode call darcs will fallback to using scp.