[Notes] [Git][BuildStream/buildstream][willsalmon/versionTagRegrex] 2 commits: Catch Non Numeric versions



Title: GitLab

Will Salmon pushed to branch willsalmon/versionTagRegrex at BuildStream / buildstream

Commits:

4 changed files:

Changes:

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

  • 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]
    

  • 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]