[Notes] [Git][BuildStream/buildstream][valentindavid/faster_startup-1.2] 16 commits: Fix broken indentation after tracking.



Title: GitLab

Valentin David pushed to branch valentindavid/faster_startup-1.2 at BuildStream / buildstream

Commits:

15 changed files:

Changes:

  • .gitlab-ci.yml
    1
    -image: buildstream/testsuite-debian:9-master-112-a9f63c5e
    
    1
    +image: buildstream/testsuite-debian:9-master-114-4cab18e3
    
    2 2
     
    
    3 3
     cache:
    
    4 4
       key: "$CI_JOB_NAME-"
    
    ... ... @@ -89,25 +89,25 @@ source_dist:
    89 89
         - coverage-linux/
    
    90 90
     
    
    91 91
     tests-debian-9:
    
    92
    -  image: buildstream/testsuite-debian:9-master-112-a9f63c5e
    
    92
    +  image: buildstream/testsuite-debian:9-master-114-4cab18e3
    
    93 93
       <<: *linux-tests
    
    94 94
     
    
    95 95
     tests-fedora-27:
    
    96
    -  image: buildstream/testsuite-fedora:27-master-112-a9f63c5e
    
    96
    +  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    97 97
       <<: *linux-tests
    
    98 98
     
    
    99 99
     tests-fedora-28:
    
    100
    -  image: buildstream/testsuite-fedora:28-master-112-a9f63c5e
    
    100
    +  image: buildstream/testsuite-fedora:28-master-114-4cab18e3
    
    101 101
       <<: *linux-tests
    
    102 102
     
    
    103 103
     tests-ubuntu-18.04:
    
    104
    -  image: buildstream/testsuite-ubuntu:18.04-master-112-a9f63c5e
    
    104
    +  image: buildstream/testsuite-ubuntu:18.04-master-114-4cab18e3
    
    105 105
       <<: *linux-tests
    
    106 106
     
    
    107 107
     tests-unix:
    
    108 108
       # Use fedora here, to a) run a test on fedora and b) ensure that we
    
    109 109
       # can get rid of ostree - this is not possible with debian-8
    
    110
    -  image: buildstream/testsuite-fedora:27-master-112-a9f63c5e
    
    110
    +  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    111 111
       stage: test
    
    112 112
       variables:
    
    113 113
         BST_FORCE_BACKEND: "unix"
    

  • buildstream/_context.py
    ... ... @@ -124,6 +124,8 @@ class Context():
    124 124
             self._workspaces = None
    
    125 125
             self._log_handle = None
    
    126 126
             self._log_filename = None
    
    127
    +        self._config_cache_quota = None
    
    128
    +        self._artifactdir_volume = None
    
    127 129
     
    
    128 130
         # load()
    
    129 131
         #
    
    ... ... @@ -187,67 +189,19 @@ class Context():
    187 189
             while not os.path.exists(artifactdir_volume):
    
    188 190
                 artifactdir_volume = os.path.dirname(artifactdir_volume)
    
    189 191
     
    
    192
    +        self._artifactdir_volume = artifactdir_volume
    
    193
    +
    
    190 194
             # We read and parse the cache quota as specified by the user
    
    191 195
             cache_quota = _yaml.node_get(cache, str, 'quota', default_value='infinity')
    
    192 196
             try:
    
    193
    -            cache_quota = utils._parse_size(cache_quota, artifactdir_volume)
    
    197
    +            cache_quota = utils._parse_size(cache_quota, self._artifactdir_volume)
    
    194 198
             except utils.UtilError as e:
    
    195 199
                 raise LoadError(LoadErrorReason.INVALID_DATA,
    
    196 200
                                 "{}\nPlease specify the value in bytes or as a % of full disk space.\n"
    
    197 201
                                 "\nValid values are, for example: 800M 10G 1T 50%\n"
    
    198 202
                                 .format(str(e))) from e
    
    199 203
     
    
    200
    -        # Headroom intended to give BuildStream a bit of leeway.
    
    201
    -        # This acts as the minimum size of cache_quota and also
    
    202
    -        # is taken from the user requested cache_quota.
    
    203
    -        #
    
    204
    -        if 'BST_TEST_SUITE' in os.environ:
    
    205
    -            headroom = 0
    
    206
    -        else:
    
    207
    -            headroom = 2e9
    
    208
    -
    
    209
    -        stat = os.statvfs(artifactdir_volume)
    
    210
    -        available_space = (stat.f_bsize * stat.f_bavail)
    
    211
    -
    
    212
    -        # Again, the artifact directory may not yet have been created yet
    
    213
    -        #
    
    214
    -        if not os.path.exists(self.artifactdir):
    
    215
    -            cache_size = 0
    
    216
    -        else:
    
    217
    -            cache_size = utils._get_dir_size(self.artifactdir)
    
    218
    -
    
    219
    -        # Ensure system has enough storage for the cache_quota
    
    220
    -        #
    
    221
    -        # If cache_quota is none, set it to the maximum it could possibly be.
    
    222
    -        #
    
    223
    -        # Also check that cache_quota is atleast as large as our headroom.
    
    224
    -        #
    
    225
    -        if cache_quota is None:  # Infinity, set to max system storage
    
    226
    -            cache_quota = cache_size + available_space
    
    227
    -        if cache_quota < headroom:  # Check minimum
    
    228
    -            raise LoadError(LoadErrorReason.INVALID_DATA,
    
    229
    -                            "Invalid cache quota ({}): ".format(utils._pretty_size(cache_quota)) +
    
    230
    -                            "BuildStream requires a minimum cache quota of 2G.")
    
    231
    -        elif cache_quota > cache_size + available_space:  # Check maximum
    
    232
    -            raise LoadError(LoadErrorReason.INVALID_DATA,
    
    233
    -                            ("Your system does not have enough available " +
    
    234
    -                             "space to support the cache quota specified.\n" +
    
    235
    -                             "You currently have:\n" +
    
    236
    -                             "- {used} of cache in use at {local_cache_path}\n" +
    
    237
    -                             "- {available} of available system storage").format(
    
    238
    -                                 used=utils._pretty_size(cache_size),
    
    239
    -                                 local_cache_path=self.artifactdir,
    
    240
    -                                 available=utils._pretty_size(available_space)))
    
    241
    -
    
    242
    -        # Place a slight headroom (2e9 (2GB) on the cache_quota) into
    
    243
    -        # cache_quota to try and avoid exceptions.
    
    244
    -        #
    
    245
    -        # Of course, we might still end up running out during a build
    
    246
    -        # if we end up writing more than 2G, but hey, this stuff is
    
    247
    -        # already really fuzzy.
    
    248
    -        #
    
    249
    -        self.cache_quota = cache_quota - headroom
    
    250
    -        self.cache_lower_threshold = self.cache_quota / 2
    
    204
    +        self._config_cache_quota = cache_quota
    
    251 205
     
    
    252 206
             # Load artifact share configuration
    
    253 207
             self.artifact_cache_specs = ArtifactCache.specs_from_config_node(defaults)
    
    ... ... @@ -571,6 +525,53 @@ class Context():
    571 525
         def get_log_filename(self):
    
    572 526
             return self._log_filename
    
    573 527
     
    
    528
    +    def set_cache_quota(self, cache_size):
    
    529
    +        # Headroom intended to give BuildStream a bit of leeway.
    
    530
    +        # This acts as the minimum size of cache_quota and also
    
    531
    +        # is taken from the user requested cache_quota.
    
    532
    +        #
    
    533
    +        if 'BST_TEST_SUITE' in os.environ:
    
    534
    +            headroom = 0
    
    535
    +        else:
    
    536
    +            headroom = 2e9
    
    537
    +
    
    538
    +        stat = os.statvfs(self._artifactdir_volume)
    
    539
    +        available_space = (stat.f_bsize * stat.f_bavail)
    
    540
    +
    
    541
    +        # Ensure system has enough storage for the cache_quota
    
    542
    +        #
    
    543
    +        # If cache_quota is none, set it to the maximum it could possibly be.
    
    544
    +        #
    
    545
    +        # Also check that cache_quota is atleast as large as our headroom.
    
    546
    +        #
    
    547
    +        cache_quota = self._config_cache_quota
    
    548
    +        if cache_quota is None:  # Infinity, set to max system storage
    
    549
    +            cache_quota = cache_size + available_space
    
    550
    +        if cache_quota < headroom:  # Check minimum
    
    551
    +            raise LoadError(LoadErrorReason.INVALID_DATA,
    
    552
    +                            "Invalid cache quota ({}): ".format(utils._pretty_size(cache_quota)) +
    
    553
    +                            "BuildStream requires a minimum cache quota of 2G.")
    
    554
    +        elif cache_quota > cache_size + available_space:  # Check maximum
    
    555
    +            raise LoadError(LoadErrorReason.INVALID_DATA,
    
    556
    +                            ("Your system does not have enough available " +
    
    557
    +                             "space to support the cache quota specified.\n" +
    
    558
    +                             "You currently have:\n" +
    
    559
    +                             "- {used} of cache in use at {local_cache_path}\n" +
    
    560
    +                             "- {available} of available system storage").format(
    
    561
    +                                 used=utils._pretty_size(cache_size),
    
    562
    +                                 local_cache_path=self.artifactdir,
    
    563
    +                                 available=utils._pretty_size(available_space)))
    
    564
    +
    
    565
    +        # Place a slight headroom (2e9 (2GB) on the cache_quota) into
    
    566
    +        # cache_quota to try and avoid exceptions.
    
    567
    +        #
    
    568
    +        # Of course, we might still end up running out during a build
    
    569
    +        # if we end up writing more than 2G, but hey, this stuff is
    
    570
    +        # already really fuzzy.
    
    571
    +        #
    
    572
    +        self.cache_quota = cache_quota - headroom
    
    573
    +        self.cache_lower_threshold = self.cache_quota / 2
    
    574
    +
    
    574 575
         # _record_message()
    
    575 576
         #
    
    576 577
         # Records the message if recording is enabled
    

  • buildstream/_frontend/app.py
    ... ... @@ -202,6 +202,10 @@ class App():
    202 202
     
    
    203 203
             Platform.create_instance(self.context)
    
    204 204
     
    
    205
    +        platform = Platform.get_platform()
    
    206
    +        cache_size = platform._artifact_cache.calculate_cache_size()
    
    207
    +        self.context.set_cache_quota(cache_size)
    
    208
    +
    
    205 209
             # Create the logger right before setting the message handler
    
    206 210
             self.logger = LogLine(self.context,
    
    207 211
                                   self._content_profile,
    

  • buildstream/_frontend/linuxapp.py
    ... ... @@ -22,12 +22,43 @@ import click
    22 22
     from .app import App
    
    23 23
     
    
    24 24
     
    
    25
    +# This trick is currently only supported on some terminals,
    
    26
    +# avoid using it where it can cause garbage to be printed
    
    27
    +# to the terminal.
    
    28
    +#
    
    29
    +def _osc_777_supported():
    
    30
    +
    
    31
    +    term = os.environ['TERM']
    
    32
    +
    
    33
    +    if term.startswith('xterm') or term.startswith('vte'):
    
    34
    +
    
    35
    +        # Since vte version 4600, upstream silently ignores
    
    36
    +        # the OSC 777 without printing garbage to the terminal.
    
    37
    +        #
    
    38
    +        # For distros like Fedora who have patched vte, this
    
    39
    +        # will trigger a desktop notification and bring attention
    
    40
    +        # to the terminal.
    
    41
    +        #
    
    42
    +        vte_version = os.environ['VTE_VERSION']
    
    43
    +        try:
    
    44
    +            vte_version_int = int(vte_version)
    
    45
    +        except ValueError:
    
    46
    +            return False
    
    47
    +
    
    48
    +        if vte_version_int >= 4600:
    
    49
    +            return True
    
    50
    +
    
    51
    +    return False
    
    52
    +
    
    53
    +
    
    25 54
     # A linux specific App implementation
    
    26 55
     #
    
    27 56
     class LinuxApp(App):
    
    28 57
     
    
    29 58
         def notify(self, title, text):
    
    30 59
     
    
    31
    -        term = os.environ['TERM']
    
    32
    -        if term in ('xterm', 'vte'):
    
    33
    -            click.echo("\033]777;notify;{};{}\007".format(title, text))
    60
    +        # Currently we only try this notification method
    
    61
    +        # of sending an escape sequence to the terminal
    
    62
    +        #
    
    63
    +        if _osc_777_supported():
    
    64
    +            click.echo("\033]777;notify;{};{}\007".format(title, text), err=True)

  • buildstream/_includes.py
    ... ... @@ -10,11 +10,15 @@ from ._exceptions import LoadError, LoadErrorReason
    10 10
     #
    
    11 11
     # Args:
    
    12 12
     #    loader (Loader): The Loader object
    
    13
    +#    copy_tree (bool): Whether to make a copy, of tree in
    
    14
    +#                      provenance. Should be true if intended to be
    
    15
    +#                      serialized.
    
    13 16
     class Includes:
    
    14 17
     
    
    15
    -    def __init__(self, loader):
    
    18
    +    def __init__(self, loader, *, copy_tree=False):
    
    16 19
             self._loader = loader
    
    17 20
             self._loaded = {}
    
    21
    +        self._copy_tree = copy_tree
    
    18 22
     
    
    19 23
         # process()
    
    20 24
         #
    
    ... ... @@ -96,10 +100,11 @@ class Includes:
    96 100
             directory = project.directory
    
    97 101
             file_path = os.path.join(directory, include)
    
    98 102
             key = (current_loader, file_path)
    
    99
    -        if file_path not in self._loaded:
    
    103
    +        if key not in self._loaded:
    
    100 104
                 self._loaded[key] = _yaml.load(os.path.join(directory, include),
    
    101 105
                                                shortname=shortname,
    
    102
    -                                           project=project)
    
    106
    +                                           project=project,
    
    107
    +                                           copy_tree=self._copy_tree)
    
    103 108
             return self._loaded[key], file_path, current_loader
    
    104 109
     
    
    105 110
         # _process_value()
    

  • buildstream/_loader/loader.py
    ... ... @@ -78,7 +78,7 @@ class Loader():
    78 78
             self._elements = {}       # Dict of elements
    
    79 79
             self._loaders = {}        # Dict of junction loaders
    
    80 80
     
    
    81
    -        self._includes = Includes(self)
    
    81
    +        self._includes = Includes(self, copy_tree=True)
    
    82 82
     
    
    83 83
         # load():
    
    84 84
         #
    

  • 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/_project.py
    ... ... @@ -416,7 +416,7 @@ class Project():
    416 416
                                  parent=parent_loader,
    
    417 417
                                  tempdir=tempdir)
    
    418 418
     
    
    419
    -        self._project_includes = Includes(self.loader)
    
    419
    +        self._project_includes = Includes(self.loader, copy_tree=False)
    
    420 420
     
    
    421 421
             project_conf_first_pass = _yaml.node_copy(self._project_conf)
    
    422 422
             self._project_includes.process(project_conf_first_pass, only_local=True)
    

  • buildstream/_version.py
    ... ... @@ -43,6 +43,7 @@ def get_config():
    43 43
         cfg.VCS = "git"
    
    44 44
         cfg.style = "pep440"
    
    45 45
         cfg.tag_prefix = ""
    
    46
    +    cfg.tag_regex = "*.*.*"
    
    46 47
         cfg.parentdir_prefix = "BuildStream-"
    
    47 48
         cfg.versionfile_source = "buildstream/_version.py"
    
    48 49
         cfg.verbose = False
    
    ... ... @@ -215,7 +216,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
    215 216
     
    
    216 217
     
    
    217 218
     @register_vcs_handler("git", "pieces_from_vcs")
    
    218
    -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    
    219
    +def git_pieces_from_vcs(tag_prefix, tag_regex, root, verbose, run_command=run_command):
    
    219 220
         """Get version from 'git describe' in the root of the source tree.
    
    220 221
     
    
    221 222
         This only gets called if the git-archive 'subst' keywords were *not*
    
    ... ... @@ -237,7 +238,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    237 238
         # if there isn't one, this yields HEX[-dirty] (no NUM)
    
    238 239
         describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
    
    239 240
                                               "--always", "--long",
    
    240
    -                                          "--match", "%s*" % tag_prefix],
    
    241
    +                                          "--match", "%s%s" % (tag_prefix, tag_regex)],
    
    241 242
                                        cwd=root)
    
    242 243
         # --long was added in git-1.5.5
    
    243 244
         if describe_out is None:
    
    ... ... @@ -505,7 +506,7 @@ def get_versions():
    505 506
                     "date": None}
    
    506 507
     
    
    507 508
         try:
    
    508
    -        pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
    
    509
    +        pieces = git_pieces_from_vcs(cfg.tag_prefix, cfg.tag_regex, root, verbose)
    
    509 510
             return render(pieces, cfg.style)
    
    510 511
         except NotThisMethod:
    
    511 512
             pass
    

  • buildstream/source.py
    ... ... @@ -752,7 +752,7 @@ class Source(Plugin):
    752 752
                     # Save the ref in the originating file
    
    753 753
                     #
    
    754 754
                     try:
    
    755
    -                    _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name)
    
    755
    +                    _yaml.dump(provenance.toplevel, provenance.filename.name)
    
    756 756
                     except OSError as e:
    
    757 757
                         raise SourceError("{}: Error saving source reference to '{}': {}"
    
    758 758
                                           .format(self, provenance.filename.name, e),
    

  • buildstream/utils.py
    ... ... @@ -481,7 +481,16 @@ def get_bst_version():
    481 481
             raise UtilError("Your git repository has no tags - BuildStream can't "
    
    482 482
                             "determine its version. Please run `git fetch --tags`.")
    
    483 483
     
    
    484
    -    return (int(versions[0]), int(versions[1]))
    
    484
    +    try:
    
    485
    +        return (int(versions[0]), int(versions[1]))
    
    486
    +    except IndexError:
    
    487
    +        raise UtilError("Cannot detect Major and Minor parts of the version\n"
    
    488
    +                        "Version: {} not in XX.YY.whatever format"
    
    489
    +                        .format(__version__))
    
    490
    +    except ValueError:
    
    491
    +        raise UtilError("Cannot convert version to integer numbers\n"
    
    492
    +                        "Version: {} not in Integer.Integer.whatever format"
    
    493
    +                        .format(__version__))
    
    485 494
     
    
    486 495
     
    
    487 496
     @contextmanager
    

  • dev-requirements.txt
    1 1
     coverage == 4.4.0
    
    2 2
     pep8
    
    3
    -pytest >= 3.1.0
    
    3
    +pylint == 2.1.1
    
    4
    +pytest >= 3.7
    
    4 5
     pytest-cov >= 2.5.0
    
    5 6
     pytest-datafiles
    
    6 7
     pytest-env
    

  • setup.cfg
    ... ... @@ -4,6 +4,7 @@ style = pep440
    4 4
     versionfile_source = buildstream/_version.py
    
    5 5
     versionfile_build = buildstream/_version.py
    
    6 6
     tag_prefix =
    
    7
    +tag_regex = *.*.*
    
    7 8
     parentdir_prefix = BuildStream-
    
    8 9
     
    
    9 10
     [aliases]
    

  • setup.py
    ... ... @@ -224,6 +224,13 @@ def get_cmdclass():
    224 224
     with open('dev-requirements.txt') as dev_reqs:
    
    225 225
         dev_requires = dev_reqs.read().splitlines()
    
    226 226
     
    
    227
    +#####################################################
    
    228
    +#     Prepare package description from README       #
    
    229
    +#####################################################
    
    230
    +with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),
    
    231
    +                       'README.rst')) as readme:
    
    232
    +    long_description = readme.read()
    
    233
    +
    
    227 234
     
    
    228 235
     #####################################################
    
    229 236
     #             Main setup() Invocation               #
    
    ... ... @@ -233,8 +240,13 @@ setup(name='BuildStream',
    233 240
           version=versioneer.get_version(),
    
    234 241
           cmdclass=get_cmdclass(),
    
    235 242
     
    
    243
    +      author='BuildStream Developers',
    
    244
    +      author_email='buildstream-list gnome org',
    
    236 245
           description='A framework for modelling build pipelines in YAML',
    
    237 246
           license='LGPL',
    
    247
    +      long_description=long_description,
    
    248
    +      long_description_content_type='text/x-rst; charset=UTF-8',
    
    249
    +      url='https://gitlab.com/BuildStream/buildstream',
    
    238 250
           packages=find_packages(exclude=('tests', 'tests.*')),
    
    239 251
           package_data={'buildstream': ['plugins/*/*.py', 'plugins/*/*.yaml',
    
    240 252
                                         'data/*.yaml', 'data/*.sh.in']},
    

  • versioneer.py
    ... ... @@ -355,6 +355,7 @@ def get_config_from_root(root):
    355 355
         cfg.versionfile_source = get(parser, "versionfile_source")
    
    356 356
         cfg.versionfile_build = get(parser, "versionfile_build")
    
    357 357
         cfg.tag_prefix = get(parser, "tag_prefix")
    
    358
    +    cfg.tag_regex = get(parser, "tag_regex") or "*"
    
    358 359
         if cfg.tag_prefix in ("''", '""'):
    
    359 360
             cfg.tag_prefix = ""
    
    360 361
         cfg.parentdir_prefix = get(parser, "parentdir_prefix")
    
    ... ... @@ -463,6 +464,7 @@ def get_config():
    463 464
         cfg.VCS = "git"
    
    464 465
         cfg.style = "%(STYLE)s"
    
    465 466
         cfg.tag_prefix = "%(TAG_PREFIX)s"
    
    467
    +    cfg.tag_regex = "%(TAG_REGEX)s"
    
    466 468
         cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s"
    
    467 469
         cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s"
    
    468 470
         cfg.verbose = False
    
    ... ... @@ -635,7 +637,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
    635 637
     
    
    636 638
     
    
    637 639
     @register_vcs_handler("git", "pieces_from_vcs")
    
    638
    -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    
    640
    +def git_pieces_from_vcs(tag_prefix, tag_regex, root, verbose, run_command=run_command):
    
    639 641
         """Get version from 'git describe' in the root of the source tree.
    
    640 642
     
    
    641 643
         This only gets called if the git-archive 'subst' keywords were *not*
    
    ... ... @@ -657,7 +659,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    657 659
         # if there isn't one, this yields HEX[-dirty] (no NUM)
    
    658 660
         describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
    
    659 661
                                               "--always", "--long",
    
    660
    -                                          "--match", "%%s*" %% tag_prefix],
    
    662
    +                                          "--match", "%%s%%s" %% (tag_prefix, tag_regex)],
    
    661 663
                                        cwd=root)
    
    662 664
         # --long was added in git-1.5.5
    
    663 665
         if describe_out is None:
    
    ... ... @@ -925,7 +927,7 @@ def get_versions():
    925 927
                     "date": None}
    
    926 928
     
    
    927 929
         try:
    
    928
    -        pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
    
    930
    +        pieces = git_pieces_from_vcs(cfg.tag_prefix, cfg.tag_regex, root, verbose)
    
    929 931
             return render(pieces, cfg.style)
    
    930 932
         except NotThisMethod:
    
    931 933
             pass
    
    ... ... @@ -1027,7 +1029,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
    1027 1029
     
    
    1028 1030
     
    
    1029 1031
     @register_vcs_handler("git", "pieces_from_vcs")
    
    1030
    -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    
    1032
    +def git_pieces_from_vcs(tag_prefix, tag_regex, root, verbose, run_command=run_command):
    
    1031 1033
         """Get version from 'git describe' in the root of the source tree.
    
    1032 1034
     
    
    1033 1035
         This only gets called if the git-archive 'subst' keywords were *not*
    
    ... ... @@ -1049,7 +1051,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    1049 1051
         # if there isn't one, this yields HEX[-dirty] (no NUM)
    
    1050 1052
         describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
    
    1051 1053
                                               "--always", "--long",
    
    1052
    -                                          "--match", "%s*" % tag_prefix],
    
    1054
    +                                          "--match", "%s%s" % (tag_prefix, tag_regex)],
    
    1053 1055
                                        cwd=root)
    
    1054 1056
         # --long was added in git-1.5.5
    
    1055 1057
         if describe_out is None:
    
    ... ... @@ -1451,7 +1453,7 @@ def get_versions(verbose=False):
    1451 1453
         from_vcs_f = handlers.get("pieces_from_vcs")
    
    1452 1454
         if from_vcs_f:
    
    1453 1455
             try:
    
    1454
    -            pieces = from_vcs_f(cfg.tag_prefix, root, verbose)
    
    1456
    +            pieces = from_vcs_f(cfg.tag_prefix, cfg.tag_regex, root, verbose)
    
    1455 1457
                 ver = render(pieces, cfg.style)
    
    1456 1458
                 if verbose:
    
    1457 1459
                     print("got version from VCS %s" % ver)
    
    ... ... @@ -1586,6 +1588,7 @@ def get_cmdclass():
    1586 1588
                                 {"DOLLAR": "$",
    
    1587 1589
                                  "STYLE": cfg.style,
    
    1588 1590
                                  "TAG_PREFIX": cfg.tag_prefix,
    
    1591
    +                             "TAG_REGEX": cfg.tag_regex,
    
    1589 1592
                                  "PARENTDIR_PREFIX": cfg.parentdir_prefix,
    
    1590 1593
                                  "VERSIONFILE_SOURCE": cfg.versionfile_source,
    
    1591 1594
                                  })
    
    ... ... @@ -1615,6 +1618,7 @@ def get_cmdclass():
    1615 1618
                                 {"DOLLAR": "$",
    
    1616 1619
                                  "STYLE": cfg.style,
    
    1617 1620
                                  "TAG_PREFIX": cfg.tag_prefix,
    
    1621
    +                             "TAG_REGEX": cfg.tag_regex,
    
    1618 1622
                                  "PARENTDIR_PREFIX": cfg.parentdir_prefix,
    
    1619 1623
                                  "VERSIONFILE_SOURCE": cfg.versionfile_source,
    
    1620 1624
                                  })
    
    ... ... @@ -1716,6 +1720,7 @@ def do_setup():
    1716 1720
             f.write(LONG % {"DOLLAR": "$",
    
    1717 1721
                             "STYLE": cfg.style,
    
    1718 1722
                             "TAG_PREFIX": cfg.tag_prefix,
    
    1723
    +                        "TAG_REGEX": cfg.tag_regex,
    
    1719 1724
                             "PARENTDIR_PREFIX": cfg.parentdir_prefix,
    
    1720 1725
                             "VERSIONFILE_SOURCE": cfg.versionfile_source,
    
    1721 1726
                             })
    



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