... |
... |
@@ -137,6 +137,7 @@ from . import Plugin |
137
|
137
|
from . import _yaml, utils
|
138
|
138
|
from ._exceptions import BstError, ImplError, ErrorDomain
|
139
|
139
|
from ._projectrefs import ProjectRefStorage
|
|
140
|
+from .plugin import CoreWarnings
|
140
|
141
|
|
141
|
142
|
|
142
|
143
|
class Consistency():
|
... |
... |
@@ -219,9 +220,9 @@ class SourceFetcher(): |
219
|
220
|
Args:
|
220
|
221
|
url (str): The url used to download.
|
221
|
222
|
"""
|
222
|
|
- # Not guaranteed to be a valid alias yet.
|
223
|
|
- # Ensuring it's a valid alias currently happens in Project.get_alias_uris
|
224
|
|
- alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
223
|
+ # NOTE: This takes advantage of _get_alias() checking against project aliases.
|
|
224
|
+ # This will consider `http://foo.com`` to have an alias of `http`.
|
|
225
|
+ alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
|
225
|
226
|
self.__alias = alias
|
226
|
227
|
|
227
|
228
|
#############################################################
|
... |
... |
@@ -459,9 +460,23 @@ class Source(Plugin): |
459
|
460
|
|
460
|
461
|
*Since: 1.2*
|
461
|
462
|
"""
|
462
|
|
- alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
463
|
+ # NOTE: This takes advantage of _get_alias() checking against project aliases.
|
|
464
|
+ # This will consider `http://foo.com`` to have an alias of `http`.
|
|
465
|
+ url_parts = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
466
|
+ alias = url_parts[0]
|
463
|
467
|
self.__expected_alias = alias
|
464
|
468
|
|
|
469
|
+ # Check and warn when detecting no valid alias.
|
|
470
|
+ project = self._get_project()
|
|
471
|
+ if alias.lower() in utils._URI_SCHEMES:
|
|
472
|
+ self.warn("{}: The use of an alias in urls is strongly advised.".format(self._get_provenance()),
|
|
473
|
+ detail="See https://buildstream.gitlab.io/buildstream/format_project.html#source-aliases",
|
|
474
|
+ warning_token=CoreWarnings.URL_WITHOUT_ALIAS)
|
|
475
|
+
|
|
476
|
+ elif not project.get_alias_uri(alias, first_pass=self.__first_pass) and len(url_parts) > 1:
|
|
477
|
+ self.warn("{}: Unknown alias '{}' in url".format(self._get_provenance(), alias),
|
|
478
|
+ warning_token=CoreWarnings.UNKNOWN_ALIAS)
|
|
479
|
+
|
465
|
480
|
def get_source_fetchers(self):
|
466
|
481
|
"""Get the objects that are used for fetching
|
467
|
482
|
|
... |
... |
@@ -525,7 +540,7 @@ class Source(Plugin): |
525
|
540
|
else:
|
526
|
541
|
# Sneakily store the alias if it hasn't already been stored
|
527
|
542
|
if not self.__expected_alias and url and utils._ALIAS_SEPARATOR in url:
|
528
|
|
- url_alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
|
|
543
|
+ url_alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
|
529
|
544
|
self.__expected_alias = url_alias
|
530
|
545
|
|
531
|
546
|
project = self._get_project()
|