Will Salmon pushed to branch master at BuildStream / buildstream
Commits:
-
9b6fac5a
by William Salmon at 2018-08-17T09:48:01Z
-
d5ed4f45
by William Salmon at 2018-08-17T09:49:23Z
-
c43af4eb
by Will Salmon at 2018-08-17T10:51:38Z
7 changed files:
- buildstream/_pipeline.py
- buildstream/plugins/sources/git.py
- buildstream/plugins/sources/ostree.py
- tests/sources/git.py
- + tests/sources/ostree.py
- + tests/sources/ostree/template/project.conf
- + tests/sources/ostree/template/repofiles/file
Changes:
... | ... | @@ -359,23 +359,14 @@ class Pipeline(): |
359 | 359 |
|
360 | 360 |
if inconsistent:
|
361 | 361 |
detail = "Exact versions are missing for the following elements:\n\n"
|
362 |
- |
|
363 |
- missingTrack = 0
|
|
364 | 362 |
for element in inconsistent:
|
365 |
- detail += " " + element._get_full_name()
|
|
363 |
+ detail += " Element: {} is inconsistent\n".format(element._get_full_name())
|
|
366 | 364 |
for source in element.sources():
|
367 |
- 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
|
|
372 |
- |
|
373 |
- detail += "\n"
|
|
365 |
+ if source._get_consistency() == Consistency.INCONSISTENT:
|
|
366 |
+ detail += " Source {} is missing ref\n".format(source)
|
|
367 |
+ detail += '\n'
|
|
368 |
+ detail += "Try tracking these elements first with `bst track`\n"
|
|
374 | 369 |
|
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 |
#############################################################
|
... | ... | @@ -309,6 +309,13 @@ class GitSource(Source): |
309 | 309 |
self.original_url = self.node_get_member(node, str, 'url')
|
310 | 310 |
self.mirror = GitMirror(self, '', self.original_url, ref)
|
311 | 311 |
self.tracking = self.node_get_member(node, str, 'track', None)
|
312 |
+ |
|
313 |
+ # At this point we now know if the source has a ref and/or a track.
|
|
314 |
+ # If it is missing both then we will be unable to track or build.
|
|
315 |
+ if self.mirror.ref is None and self.tracking is None:
|
|
316 |
+ raise SourceError("{}: Git sources require a ref and/or track".format(self),
|
|
317 |
+ reason="missing-track-and-ref")
|
|
318 |
+ |
|
312 | 319 |
self.checkout_submodules = self.node_get_member(node, bool, 'checkout-submodules', True)
|
313 | 320 |
self.submodules = []
|
314 | 321 |
|
... | ... | @@ -73,6 +73,12 @@ class OSTreeSource(Source): |
73 | 73 |
self.mirror = os.path.join(self.get_mirror_directory(),
|
74 | 74 |
utils.url_directory_name(self.original_url))
|
75 | 75 |
|
76 |
+ # At this point we now know if the source has a ref and/or a track.
|
|
77 |
+ # If it is missing both then we will be unable to track or build.
|
|
78 |
+ if self.ref is None and self.tracking is None:
|
|
79 |
+ raise SourceError("{}: OSTree sources require a ref and/or track".format(self),
|
|
80 |
+ reason="missing-track-and-ref")
|
|
81 |
+ |
|
76 | 82 |
# (optional) Not all repos are signed. But if they are, get the gpg key
|
77 | 83 |
self.gpg_key_path = None
|
78 | 84 |
if self.node_get_member(node, str, 'gpg-key', None):
|
1 |
+#
|
|
2 |
+# Copyright (C) 2018 Codethink Limited
|
|
3 |
+# Copyright (C) 2018 Bloomberg Finance LP
|
|
4 |
+#
|
|
5 |
+# This program is free software; you can redistribute it and/or
|
|
6 |
+# modify it under the terms of the GNU Lesser General Public
|
|
7 |
+# License as published by the Free Software Foundation; either
|
|
8 |
+# version 2 of the License, or (at your option) any later version.
|
|
9 |
+#
|
|
10 |
+# This library is distributed in the hope that it will be useful,
|
|
11 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 |
+# Lesser General Public License for more details.
|
|
14 |
+#
|
|
15 |
+# You should have received a copy of the GNU Lesser General Public
|
|
16 |
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
+#
|
|
18 |
+# Authors: Tristan Van Berkom <tristan vanberkom codethink co uk>
|
|
19 |
+# Jonathan Maw <jonathan maw codethink co uk>
|
|
20 |
+# William Salmon <will salmon codethink co uk>
|
|
21 |
+#
|
|
22 |
+ |
|
1 | 23 |
import os
|
2 | 24 |
import pytest
|
3 | 25 |
|
... | ... | @@ -383,21 +405,6 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): |
383 | 405 |
_yaml.dump(element, os.path.join(project, 'target.bst'))
|
384 | 406 |
|
385 | 407 |
# Track will encounter an inconsistent submodule without any ref
|
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')
|
|
389 |
- |
|
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
|
|
394 |
- |
|
395 |
- # Track will encounter an inconsistent submodule without any ref
|
|
396 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
397 |
- result.assert_main_error(ErrorDomain.PIPELINE, 'inconsistent-pipeline')
|
|
408 |
+ result = cli.run(project=project, args=['show', 'target.bst'])
|
|
409 |
+ result.assert_main_error(ErrorDomain.SOURCE, "missing-track-and-ref")
|
|
398 | 410 |
result.assert_task_error(None, None)
|
399 |
- |
|
400 |
- # 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
|
1 |
+#
|
|
2 |
+# Copyright (C) 2018 Bloomberg Finance LP
|
|
3 |
+#
|
|
4 |
+# This program is free software; you can redistribute it and/or
|
|
5 |
+# modify it under the terms of the GNU Lesser General Public
|
|
6 |
+# License as published by the Free Software Foundation; either
|
|
7 |
+# version 2 of the License, or (at your option) any later version.
|
|
8 |
+#
|
|
9 |
+# This library is distributed in the hope that it will be useful,
|
|
10 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12 |
+# Lesser General Public License for more details.
|
|
13 |
+#
|
|
14 |
+# You should have received a copy of the GNU Lesser General Public
|
|
15 |
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
+#
|
|
17 |
+# Authors: William Salmon <will salmon codethink co uk>
|
|
18 |
+#
|
|
19 |
+ |
|
20 |
+import os
|
|
21 |
+import pytest
|
|
22 |
+ |
|
23 |
+from buildstream._exceptions import ErrorDomain
|
|
24 |
+from buildstream import _yaml
|
|
25 |
+ |
|
26 |
+from tests.testutils import cli, create_repo
|
|
27 |
+ |
|
28 |
+DATA_DIR = os.path.join(
|
|
29 |
+ os.path.dirname(os.path.realpath(__file__)),
|
|
30 |
+ 'ostree',
|
|
31 |
+)
|
|
32 |
+ |
|
33 |
+ |
|
34 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
|
|
35 |
+def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles):
|
|
36 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
37 |
+ |
|
38 |
+ # Create the repo from 'repofiles' subdir
|
|
39 |
+ repo = create_repo('ostree', str(tmpdir))
|
|
40 |
+ ref = repo.create(os.path.join(project, 'repofiles'))
|
|
41 |
+ |
|
42 |
+ # Write out our test target
|
|
43 |
+ ostreesource = repo.source_config(ref=None)
|
|
44 |
+ ostreesource.pop('track')
|
|
45 |
+ element = {
|
|
46 |
+ 'kind': 'import',
|
|
47 |
+ 'sources': [
|
|
48 |
+ ostreesource
|
|
49 |
+ ]
|
|
50 |
+ }
|
|
51 |
+ |
|
52 |
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
53 |
+ |
|
54 |
+ # Track will encounter an inconsistent submodule without any ref
|
|
55 |
+ result = cli.run(project=project, args=['show', 'target.bst'])
|
|
56 |
+ result.assert_main_error(ErrorDomain.SOURCE, "missing-track-and-ref")
|
|
57 |
+ result.assert_task_error(None, None)
|
1 |
+# Basic project
|
|
2 |
+name: foo
|