Merge remote-tracking branch 'origin/pr/155' into master

This commit is contained in:
lilydjwg 2020-10-02 12:38:13 +08:00
commit 494c67beb0
2 changed files with 9 additions and 1 deletions

View File

@ -280,7 +280,7 @@ def substitute_version(
from_pattern = conf.get('from_pattern')
if from_pattern:
to_pattern = conf.get('to_pattern')
if not to_pattern:
if to_pattern is None:
raise ValueError("from_pattern exists but to_pattern doesn't")
return re.sub(from_pattern, to_pattern, version)

View File

@ -34,6 +34,14 @@ async def test_substitute_regex_missing_ok(get_version):
"to_pattern": r"r\1.\2",
}) == "r15"
async def test_substitute_regex_empty_to_pattern(get_version):
assert await get_version("example", {
"source": "manual",
"manual": "15-debian",
"from_pattern": r"-\w+$",
"to_pattern": r"",
}) == "15"
async def test_substitute_prefix_has_higher_priority(get_version):
assert await get_version("example", {
"source": "manual",