Will Salmon pushed to branch willsalmon/versionTagRegrex at BuildStream / buildstream
Commits:
-
13e213eb
by William Salmon at 2018-08-03T15:39:02Z
-
dd1ec66c
by William Salmon at 2018-08-03T15:39:57Z
2 changed files:
Changes:
... | ... | @@ -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
|
... | ... | @@ -484,8 +484,13 @@ 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]))
|
|
488 |
- |
|
487 |
+ try:
|
|
488 |
+ return (int(versions[0]), int(versions[1]))
|
|
489 |
+ except Exception:
|
|
490 |
+ # We should try a mitigation hear, like falling back to a previous version.
|
|
491 |
+ raise UtilError("Cannot detect numeric Major and Minor version numbers\n"
|
|
492 |
+ "Version: {} not in Interger.Interger.whatever format"
|
|
493 |
+ .format(__version__))
|
|
489 | 494 |
|
490 | 495 |
@contextmanager
|
491 | 496 |
def save_file_atomic(filename, mode='w', *, buffering=-1, encoding=None,
|