@@ -4,9 +4,10 @@ package workers.deps
4
4
import common .args .ArgsUtil
5
5
import common .args .ArgsUtil .PathArgumentType
6
6
import common .args .implicits .*
7
+ import common .error .AnnexWorkerError
7
8
import common .interrupt .InterruptUtil
8
- import common .worker .WorkerMain
9
9
import common .sandbox .SandboxUtil
10
+ import common .worker .WorkerMain
10
11
import workers .common .AnnexMapper
11
12
import workers .common .FileUtil
12
13
import java .io .{File , PrintStream }
@@ -163,11 +164,6 @@ object DepsRunner extends WorkerMain[Unit] {
163
164
} else {
164
165
Nil
165
166
}
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
- }
171
167
172
168
InterruptUtil .throwIfInterrupted()
173
169
val labelsToAdd = if (workRequest.checkDirect) {
@@ -182,16 +178,26 @@ object DepsRunner extends WorkerMain[Unit] {
182
178
} else {
183
179
Nil
184
180
}
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
- }
190
181
191
182
if (labelsToAdd.isEmpty && labelsToRemove.isEmpty) {
192
183
try Files .createFile(workRequest.successFile)
193
184
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())
194
199
}
200
+
195
201
InterruptUtil .throwIfInterrupted()
196
202
}
197
203
}
0 commit comments