[Notes] [Git][BuildStream/buildstream][Qinusty/597-non-alias-url-fix] 4 commits: Pipeline: Skip except_elements logic if no elements to except



Title: GitLab

Qinusty pushed to branch Qinusty/597-non-alias-url-fix at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_pipeline.py
    ... ... @@ -235,6 +235,9 @@ class Pipeline():
    235 235
         #                       exceptions removed
    
    236 236
         #
    
    237 237
         def except_elements(self, targets, elements, except_targets):
    
    238
    +        if not except_targets:
    
    239
    +            return elements
    
    240
    +
    
    238 241
             targeted = list(self.dependencies(targets, Scope.ALL))
    
    239 242
             visited = []
    
    240 243
     
    

  • buildstream/plugin.py
    ... ... @@ -757,6 +757,16 @@ class CoreWarnings():
    757 757
         which is found to be invalid based on the configured track
    
    758 758
         """
    
    759 759
     
    
    760
    +    URL_WITHOUT_ALIAS = "url-without-alias"
    
    761
    +    """
    
    762
    +    This warning will be produced when a source is configured with a url which does not contain an alias.
    
    763
    +    """
    
    764
    +
    
    765
    +    UNKNOWN_ALIAS = "unknown-alias"
    
    766
    +    """
    
    767
    +    This warning will be produced when a source is configured with a url which does not contain an alias.
    
    768
    +    """
    
    769
    +
    
    760 770
     
    
    761 771
     __CORE_WARNINGS = [
    
    762 772
         value
    

  • buildstream/source.py
    ... ... @@ -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,7 @@ 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
    +        alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
    
    225 224
             self.__alias = alias
    
    226 225
     
    
    227 226
         #############################################################
    
    ... ... @@ -459,8 +458,8 @@ class Source(Plugin):
    459 458
     
    
    460 459
             *Since: 1.2*
    
    461 460
             """
    
    462
    -        alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
    
    463
    -        self.__expected_alias = alias
    
    461
    +        url_alias = url.split(utils._ALIAS_SEPARATOR, 1)[0]
    
    462
    +        self.__expected_alias = url_alias
    
    464 463
     
    
    465 464
         def get_source_fetchers(self):
    
    466 465
             """Get the objects that are used for fetching
    
    ... ... @@ -505,6 +504,7 @@ class Source(Plugin):
    505 504
             Returns:
    
    506 505
                str: The fully qualified url, with aliases resolved
    
    507 506
             """
    
    507
    +        self.__validate_raw_url(url)
    
    508 508
             # Alias overriding can happen explicitly (by command-line) or
    
    509 509
             # implicitly (the Source being constructed with an __alias_override).
    
    510 510
             if alias_override or self.__alias_override:
    
    ... ... @@ -525,8 +525,7 @@ class Source(Plugin):
    525 525
             else:
    
    526 526
                 # Sneakily store the alias if it hasn't already been stored
    
    527 527
                 if not self.__expected_alias and url and utils._ALIAS_SEPARATOR in url:
    
    528
    -                url_alias, _ = url.split(utils._ALIAS_SEPARATOR, 1)
    
    529
    -                self.__expected_alias = url_alias
    
    528
    +                self.mark_download_url(url)
    
    530 529
     
    
    531 530
                 project = self._get_project()
    
    532 531
                 return project.translate_url(url, first_pass=self.__first_pass)
    
    ... ... @@ -988,3 +987,23 @@ class Source(Plugin):
    988 987
     
    
    989 988
                 if src.get_consistency() == Consistency.RESOLVED:
    
    990 989
                     src._fetch(previous_sources[0:index])
    
    990
    +
    
    991
    +    # __validate_raw_url():
    
    992
    +    #
    
    993
    +    # Validates a url prior to url substitution.
    
    994
    +    # This checks the url and produces warnings.
    
    995
    +    #
    
    996
    +    def __validate_raw_url(self, url):
    
    997
    +        url_parts = url.split(utils._ALIAS_SEPARATOR, 1)
    
    998
    +        alias = url_parts[0]
    
    999
    +
    
    1000
    +        # Check and warn when detecting no valid alias.
    
    1001
    +        project = self._get_project()
    
    1002
    +        if alias.lower() in utils._URI_SCHEMES:
    
    1003
    +            self.warn("{}: The use of an alias in urls is strongly advised.".format(self._get_provenance()),
    
    1004
    +                      detail="See https://buildstream.gitlab.io/buildstream/format_project.html#source-aliases",
    
    1005
    +                      warning_token=CoreWarnings.URL_WITHOUT_ALIAS)
    
    1006
    +
    
    1007
    +        elif not project.get_alias_uri(alias, first_pass=self.__first_pass) and len(url_parts) > 1:
    
    1008
    +            self.warn("{}: Unknown alias '{}' in url".format(self._get_provenance(), alias),
    
    1009
    +                      warning_token=CoreWarnings.UNKNOWN_ALIAS)

  • buildstream/utils.py
    ... ... @@ -47,6 +47,7 @@ _magic_timestamp = calendar.timegm([2011, 11, 11, 11, 11, 11])
    47 47
     
    
    48 48
     # The separator we use for user specified aliases
    
    49 49
     _ALIAS_SEPARATOR = ':'
    
    50
    +_URI_SCHEMES = ["http", "https", "ftp", "file", "git", "sftp", "ssh"]
    
    50 51
     
    
    51 52
     
    
    52 53
     class UtilError(BstError):
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]