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/26 07:43:24 UTC

[buildstream] 03/05: source.py: Raise a fatal-able warning when using an unaliased source.

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

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

commit 172f90d3400bf0c071fbdf291698256cac4620ff
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Aug 7 16:25:13 2021 +0900

    source.py: Raise a fatal-able warning when using an unaliased source.
    
    We do this at Source.mark_download_url() time, which as a matter of policy,
    must be used at project configure() time if Source.translate_url() is not
    used instead, this should ensure that aliases are verified to be used
    at load time, if not, it is a bug in the respective plugin.
    
    We will not be able to catch unaliased URLs unless they are specified
    in the yaml, for example, if you have not specified all of the submodules
    in use for a git source.
---
 buildstream/source.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/buildstream/source.py b/buildstream/source.py
index 08742a6..4381025 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -152,6 +152,7 @@ from contextlib import contextmanager
 
 from . import Plugin
 from . import _yaml, utils
+from .types import CoreWarnings
 from ._exceptions import BstError, ImplError, ErrorDomain
 from ._projectrefs import ProjectRefStorage
 
@@ -613,6 +614,15 @@ class Source(Plugin):
             assert (url in self.__marked_urls or not _extract_alias(url)), \
                 "URL was not seen at configure time: {}".format(url)
 
+        alias = _extract_alias(url)
+
+        # Issue a (fatal-able) warning if the source used a URL without specifying an alias
+        if not alias:
+            self.warn(
+                "{}: Use of unaliased source download URL: {}".format(self, url),
+                warning_token=CoreWarnings.UNALIASED_URL,
+            )
+
     def get_project_directory(self):
         """Fetch the project base directory