Will Salmon pushed to branch willsalmon/APIFix at BuildStream / buildstream
Commits:
-
0a037947
by William Salmon at 2018-08-09T15:59:41Z
3 changed files:
Changes:
... | ... | @@ -360,22 +360,13 @@ class Pipeline(): |
360 | 360 |
if inconsistent:
|
361 | 361 |
detail = "Exact versions are missing for the following elements:\n\n"
|
362 | 362 |
|
363 |
- missingTrack = 0
|
|
364 | 363 |
for element in inconsistent:
|
365 | 364 |
detail += " " + element._get_full_name()
|
366 | 365 |
for source in element.sources():
|
367 | 366 |
if not source._get_consistency() and not source.get_ref():
|
368 |
- if hasattr(source, 'tracking') and source.tracking is None:
|
|
369 |
- detail += ": Source {} is missing ref and track. ".format(source._get_full_name()) + \
|
|
370 |
- "Please specify a ref or branch/tag to track."
|
|
371 |
- missingTrack = 1
|
|
367 |
+ detail += ": Source {} is missing ref\n".format(source)
|
|
368 |
+ detail += "\nTry tracking these elements first with `bst track`\n"
|
|
372 | 369 |
|
373 |
- detail += "\n"
|
|
374 |
- |
|
375 |
- if missingTrack:
|
|
376 |
- detail += "\nThen track these elements with `bst track`\n"
|
|
377 |
- else:
|
|
378 |
- detail += "\nTry tracking these elements first with `bst track`\n"
|
|
379 | 370 |
raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline")
|
380 | 371 |
|
381 | 372 |
#############################################################
|
... | ... | @@ -81,6 +81,7 @@ from configparser import RawConfigParser |
81 | 81 |
|
82 | 82 |
from buildstream import Source, SourceError, Consistency, SourceFetcher
|
83 | 83 |
from buildstream import utils
|
84 |
+from buildstream._exceptions import LoadError, LoadErrorReason
|
|
84 | 85 |
|
85 | 86 |
GIT_MODULES = '.gitmodules'
|
86 | 87 |
|
... | ... | @@ -300,6 +301,12 @@ class GitSource(Source): |
300 | 301 |
self.original_url = self.node_get_member(node, str, 'url')
|
301 | 302 |
self.mirror = GitMirror(self, '', self.original_url, ref)
|
302 | 303 |
self.tracking = self.node_get_member(node, str, 'track', None)
|
304 |
+ |
|
305 |
+ # At this point we now know if the source has a ref and/or a track.
|
|
306 |
+ # If it is missing both then we will be unable to track or build.
|
|
307 |
+ if self.mirror.ref is None and self.tracking is None:
|
|
308 |
+ raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Git sources require a ref and/or track".format(self))
|
|
309 |
+ |
|
303 | 310 |
self.checkout_submodules = self.node_get_member(node, bool, 'checkout-submodules', True)
|
304 | 311 |
self.submodules = []
|
305 | 312 |
|
1 | 1 |
import os
|
2 | 2 |
import pytest
|
3 | 3 |
|
4 |
-from buildstream._exceptions import ErrorDomain
|
|
4 |
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
|
5 | 5 |
from buildstream import _yaml
|
6 | 6 |
|
7 | 7 |
from tests.testutils import cli, create_repo
|
... | ... | @@ -384,20 +384,16 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): |
384 | 384 |
|
385 | 385 |
# Track will encounter an inconsistent submodule without any ref
|
386 | 386 |
result = cli.run(project=project, args=['track', 'target.bst'])
|
387 |
- result.assert_main_error(ErrorDomain.STREAM, None)
|
|
388 |
- result.assert_task_error(ErrorDomain.SOURCE, 'track-attempt-no-track')
|
|
387 |
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
|
388 |
+ result.assert_task_error(None, None)
|
|
389 | 389 |
|
390 | 390 |
# Assert that we are just fine without it, and emit a warning to the user.
|
391 |
- assert "FAILURE git source at" in result.stderr
|
|
392 |
- assert "Without a tracking branch ref can not be updated. Please " + \
|
|
393 |
- "provide a ref or a track." in result.stderr
|
|
391 |
+ assert "Git sources require a ref and/or track" in result.stderr
|
|
394 | 392 |
|
395 | 393 |
# Track will encounter an inconsistent submodule without any ref
|
396 | 394 |
result = cli.run(project=project, args=['build', 'target.bst'])
|
397 |
- result.assert_main_error(ErrorDomain.PIPELINE, 'inconsistent-pipeline')
|
|
395 |
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
|
398 | 396 |
result.assert_task_error(None, None)
|
399 | 397 |
|
400 | 398 |
# Assert that we are just fine without it, and emit a warning to the user.
|
401 |
- assert "Exact versions are missing for the following elements" in result.stderr
|
|
402 |
- assert "is missing ref and track." in result.stderr
|
|
403 |
- assert "Then track these elements with `bst track`" in result.stderr
|
|
399 |
+ assert "Git sources require a ref and/or track" in result.stderr
|