mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
parent
809a6becb6
commit
5bf12a49ce
3 changed files with 90 additions and 68 deletions
|
|
@ -85,37 +85,38 @@ COMPOSITE_PART_PATTERNS = {
|
||||||
|
|
||||||
|
|
||||||
PART_PATTERNS = {
|
PART_PATTERNS = {
|
||||||
'year' : r"\d{4}",
|
'year' : r"\d{4}",
|
||||||
'month' : r"(?:0[0-9]|1[0-2])",
|
'month' : r"(?:0[0-9]|1[0-2])",
|
||||||
'build_no' : r"\d{4,}",
|
'month_short': r"(?:1[0-2]|[1-9])",
|
||||||
'pep440_tag': r"(?:a|b|dev|rc|post)?\d*",
|
'build_no' : r"\d{4,}",
|
||||||
'tag' : r"(?:alpha|beta|dev|rc|post|final)",
|
'pep440_tag' : r"(?:a|b|dev|rc|post)?\d*",
|
||||||
'yy' : r"\d{2}",
|
'tag' : r"(?:alpha|beta|dev|rc|post|final)",
|
||||||
'yyyy' : r"\d{4}",
|
'yy' : r"\d{2}",
|
||||||
'quarter' : r"[1-4]",
|
'yyyy' : r"\d{4}",
|
||||||
'iso_week' : r"(?:[0-4]\d|5[0-3])",
|
'quarter' : r"[1-4]",
|
||||||
'us_week' : r"(?:[0-4]\d|5[0-3])",
|
'iso_week' : r"(?:[0-4]\d|5[0-3])",
|
||||||
'dom' : r"(0[1-9]|[1-2][0-9]|3[0-1])",
|
'us_week' : r"(?:[0-4]\d|5[0-3])",
|
||||||
'doy' : r"(?:[0-2]\d\d|3[0-5][0-9]|36[0-6])",
|
'dom' : r"(0[1-9]|[1-2][0-9]|3[0-1])",
|
||||||
'MAJOR' : r"\d+",
|
'doy' : r"(?:[0-2]\d\d|3[0-5][0-9]|36[0-6])",
|
||||||
'MINOR' : r"\d+",
|
'MAJOR' : r"\d+",
|
||||||
'MM' : r"\d{2,}",
|
'MINOR' : r"\d+",
|
||||||
'MMM' : r"\d{3,}",
|
'MM' : r"\d{2,}",
|
||||||
'MMMM' : r"\d{4,}",
|
'MMM' : r"\d{3,}",
|
||||||
'MMMMM' : r"\d{5,}",
|
'MMMM' : r"\d{4,}",
|
||||||
'PATCH' : r"\d+",
|
'MMMMM' : r"\d{5,}",
|
||||||
'PP' : r"\d{2,}",
|
'PATCH' : r"\d+",
|
||||||
'PPP' : r"\d{3,}",
|
'PP' : r"\d{2,}",
|
||||||
'PPPP' : r"\d{4,}",
|
'PPP' : r"\d{3,}",
|
||||||
'PPPPP' : r"\d{5,}",
|
'PPPP' : r"\d{4,}",
|
||||||
'bid' : r"\d{4,}",
|
'PPPPP' : r"\d{5,}",
|
||||||
'BID' : r"[1-9]\d*",
|
'bid' : r"\d{4,}",
|
||||||
'BB' : r"[1-9]\d{1,}",
|
'BID' : r"[1-9]\d*",
|
||||||
'BBB' : r"[1-9]\d{2,}",
|
'BB' : r"[1-9]\d{1,}",
|
||||||
'BBBB' : r"[1-9]\d{3,}",
|
'BBB' : r"[1-9]\d{2,}",
|
||||||
'BBBBB' : r"[1-9]\d{4,}",
|
'BBBB' : r"[1-9]\d{3,}",
|
||||||
'BBBBBB' : r"[1-9]\d{5,}",
|
'BBBBB' : r"[1-9]\d{4,}",
|
||||||
'BBBBBBB' : r"[1-9]\d{6,}",
|
'BBBBBB' : r"[1-9]\d{5,}",
|
||||||
|
'BBBBBBB' : r"[1-9]\d{6,}",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -129,12 +130,13 @@ FULL_PART_FORMATS = {
|
||||||
# NOTE (mb 2019-01-04): since release is optional, it
|
# NOTE (mb 2019-01-04): since release is optional, it
|
||||||
# is treates specially in version.format
|
# is treates specially in version.format
|
||||||
# 'release' : "-{tag}",
|
# 'release' : "-{tag}",
|
||||||
'month' : "{month:02}",
|
'month' : "{month:02}",
|
||||||
'build_no': "{bid}",
|
'month_short': "{month}",
|
||||||
'iso_week': "{iso_week:02}",
|
'build_no' : "{bid}",
|
||||||
'us_week' : "{us_week:02}",
|
'iso_week' : "{iso_week:02}",
|
||||||
'dom' : "{dom:02}",
|
'us_week' : "{us_week:02}",
|
||||||
'doy' : "{doy:03}",
|
'dom' : "{dom:02}",
|
||||||
|
'doy' : "{doy:03}",
|
||||||
# depricated
|
# depricated
|
||||||
'pep440_version': "{year}{month:02}.{BID}{pep440_tag}",
|
'pep440_version': "{year}{month:02}.{BID}{pep440_tag}",
|
||||||
'version' : "v{year}{month:02}.{bid}{release}",
|
'version' : "v{year}{month:02}.{bid}{release}",
|
||||||
|
|
|
||||||
|
|
@ -21,37 +21,38 @@ TODAY = dt.datetime.utcnow().date()
|
||||||
|
|
||||||
|
|
||||||
PATTERN_PART_FIELDS = {
|
PATTERN_PART_FIELDS = {
|
||||||
'year' : 'year',
|
'year' : 'year',
|
||||||
'month' : 'month',
|
'month' : 'month',
|
||||||
'pep440_tag': 'tag',
|
'month_short': 'month',
|
||||||
'tag' : 'tag',
|
'pep440_tag' : 'tag',
|
||||||
'yy' : 'year',
|
'tag' : 'tag',
|
||||||
'yyyy' : 'year',
|
'yy' : 'year',
|
||||||
'quarter' : 'quarter',
|
'yyyy' : 'year',
|
||||||
'iso_week' : 'iso_week',
|
'quarter' : 'quarter',
|
||||||
'us_week' : 'us_week',
|
'iso_week' : 'iso_week',
|
||||||
'dom' : 'dom',
|
'us_week' : 'us_week',
|
||||||
'doy' : 'doy',
|
'dom' : 'dom',
|
||||||
'MAJOR' : 'major',
|
'doy' : 'doy',
|
||||||
'MINOR' : 'minor',
|
'MAJOR' : 'major',
|
||||||
'MM' : 'minor',
|
'MINOR' : 'minor',
|
||||||
'MMM' : 'minor',
|
'MM' : 'minor',
|
||||||
'MMMM' : 'minor',
|
'MMM' : 'minor',
|
||||||
'MMMMM' : 'minor',
|
'MMMM' : 'minor',
|
||||||
'PP' : 'patch',
|
'MMMMM' : 'minor',
|
||||||
'PPP' : 'patch',
|
'PP' : 'patch',
|
||||||
'PPPP' : 'patch',
|
'PPP' : 'patch',
|
||||||
'PPPPP' : 'patch',
|
'PPPP' : 'patch',
|
||||||
'PATCH' : 'patch',
|
'PPPPP' : 'patch',
|
||||||
'build_no' : 'bid',
|
'PATCH' : 'patch',
|
||||||
'bid' : 'bid',
|
'build_no' : 'bid',
|
||||||
'BID' : 'bid',
|
'bid' : 'bid',
|
||||||
'BB' : 'bid',
|
'BID' : 'bid',
|
||||||
'BBB' : 'bid',
|
'BB' : 'bid',
|
||||||
'BBBB' : 'bid',
|
'BBB' : 'bid',
|
||||||
'BBBBB' : 'bid',
|
'BBBB' : 'bid',
|
||||||
'BBBBBB' : 'bid',
|
'BBBBB' : 'bid',
|
||||||
'BBBBBBB' : 'bid',
|
'BBBBBB' : 'bid',
|
||||||
|
'BBBBBBB' : 'bid',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,25 @@ def test_re_pattern_parts(part_name, line, expected):
|
||||||
assert result_val == expected, (part_name, line)
|
assert result_val == expected, (part_name, line)
|
||||||
|
|
||||||
|
|
||||||
|
PATTERN_CASES = [
|
||||||
|
(r"v{year}.{month}.{MINOR}" , "v2017.11.1" , "v2017.11.1"),
|
||||||
|
(r"v{year}.{month}.{MINOR}" , "v2017.07.12", "v2017.07.12"),
|
||||||
|
(r"v{year}.{month_short}.{MINOR}", "v2017.11.1" , "v2017.11.1"),
|
||||||
|
(r"v{year}.{month_short}.{MINOR}", "v2017.7.12" , "v2017.7.12"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("pattern_str, line, expected", PATTERN_CASES)
|
||||||
|
def test_patterns(pattern_str, line, expected):
|
||||||
|
pattern_re = patterns.compile_pattern(pattern_str)
|
||||||
|
result = pattern_re.search(line)
|
||||||
|
if result is None:
|
||||||
|
assert expected is None, (pattern_str, line)
|
||||||
|
else:
|
||||||
|
result_val = result.group(0)
|
||||||
|
assert result_val == expected, (pattern_str, line)
|
||||||
|
|
||||||
|
|
||||||
CLI_MAIN_FIXTURE = """
|
CLI_MAIN_FIXTURE = """
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(version="v201812.0123-beta")
|
@click.version_option(version="v201812.0123-beta")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue