Skip to content

Commit 9db3ce8

Browse files
authoredMar 31, 2025··
Merge pull request #89 from lucidsoftware/davidneil-non-zero-exit-code
Add non-zero exit code when deps check fails
2 parents 009f97d + 11f30e4 commit 9db3ce8

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed
 

‎src/main/scala/higherkindness/rules_scala/workers/deps/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ scala_binary(
99
visibility = ["//visibility:public"],
1010
deps = [
1111
"//src/main/scala/higherkindness/rules_scala/common/args",
12+
"//src/main/scala/higherkindness/rules_scala/common/error",
1213
"//src/main/scala/higherkindness/rules_scala/common/interrupt",
1314
"//src/main/scala/higherkindness/rules_scala/common/sandbox",
1415
"//src/main/scala/higherkindness/rules_scala/common/worker",

‎src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala

+17-11
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package workers.deps
44
import common.args.ArgsUtil
55
import common.args.ArgsUtil.PathArgumentType
66
import common.args.implicits.*
7+
import common.error.AnnexWorkerError
78
import common.interrupt.InterruptUtil
8-
import common.worker.WorkerMain
99
import common.sandbox.SandboxUtil
10+
import common.worker.WorkerMain
1011
import workers.common.AnnexMapper
1112
import workers.common.FileUtil
1213
import java.io.{File, PrintStream}
@@ -163,11 +164,6 @@ object DepsRunner extends WorkerMain[Unit] {
163164
} else {
164165
Nil
165166
}
166-
labelsToRemove.foreach { depLabel =>
167-
out.println(s"Target '$depLabel' not used, please remove it from the deps.")
168-
out.println(s"You can use the following buildozer command:")
169-
out.println(s"buildozer 'remove deps $depLabel' ${workRequest.label}")
170-
}
171167

172168
InterruptUtil.throwIfInterrupted()
173169
val labelsToAdd = if (workRequest.checkDirect) {
@@ -182,16 +178,26 @@ object DepsRunner extends WorkerMain[Unit] {
182178
} else {
183179
Nil
184180
}
185-
labelsToAdd.foreach { depLabel =>
186-
out.println(s"Target '$depLabel' is used but isn't explicitly declared, please add it to the deps.")
187-
out.println(s"You can use the following buildozer command:")
188-
out.println(s"buildozer 'add deps $depLabel' ${workRequest.label}")
189-
}
190181

191182
if (labelsToAdd.isEmpty && labelsToRemove.isEmpty) {
192183
try Files.createFile(workRequest.successFile)
193184
catch { case _: FileAlreadyExistsException => }
185+
} else {
186+
val errorMessage = new StringBuilder()
187+
labelsToRemove.foreach { depLabel =>
188+
errorMessage.append(s"Target '$depLabel' not used, please remove it from the deps.\n")
189+
errorMessage.append("You can use the following buildozer command:\n")
190+
errorMessage.append(s"buildozer 'remove deps $depLabel' ${workRequest.label}\n")
191+
}
192+
193+
labelsToAdd.foreach { depLabel =>
194+
errorMessage.append(s"Target '$depLabel' is used but isn't explicitly declared, please add it to the deps.\n")
195+
errorMessage.append("You can use the following buildozer command:\n")
196+
errorMessage.append(s"buildozer 'add deps $depLabel' ${workRequest.label}\n")
197+
}
198+
throw new AnnexWorkerError(1, errorMessage.result())
194199
}
200+
195201
InterruptUtil.throwIfInterrupted()
196202
}
197203
}

0 commit comments

Comments
 (0)
Please sign in to comment.