You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/08/07 07:47:38 UTC

[buildstream] 03/03: source.py: Raise an error at load time when encountering unresolved source aliases

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/unaliased-sources
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 91c5b11abcf293d8fa55c87a54c92c8da9386fc7
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Aug 7 16:35:15 2021 +0900

    source.py: Raise an error at load time when encountering unresolved source aliases
    
    This fixes issue #1119
---
 src/buildstream/source.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 4450289..7a7c4f2 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -663,6 +663,16 @@ class Source(Plugin):
                 warning_token=CoreWarnings.UNALIASED_URL,
             )
 
+        # If there is an alias in use, ensure that it exists in the project
+        if alias:
+            project = self._get_project()
+            alias_uri = project.get_alias_uri(alias, first_pass=self.__first_pass)
+            if alias_uri is None:
+                raise SourceError(
+                    "{}: Unable to find alias '{}' for aliased URL: {} sources".format(self, alias, url),
+                    reason="missing-source-alias",
+                )
+
     def get_project_directory(self) -> str:
         """Fetch the project base directory