@@ -4,9 +4,10 @@ package workers.deps
44import common .args .ArgsUtil
55import common .args .ArgsUtil .PathArgumentType
66import common .args .implicits .*
7+ import common .error .AnnexWorkerError
78import common .interrupt .InterruptUtil
8- import common .worker .WorkerMain
99import common .sandbox .SandboxUtil
10+ import common .worker .WorkerMain
1011import workers .common .AnnexMapper
1112import workers .common .FileUtil
1213import 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