lib.version.Dependency.constraint_str(): Delimit by comma
A multi-boundary constraint is rendered as 'foo >= 1.2.3-45 foo < 1.2.4', which is invalid: the RPM spec template writes the Requires: line from it verbatim, and RPM entries are comma-separated, so the second clause is swallowed into one bad entry. Debian's format_depends() normalizes runs of whitespace to commas, so it tolerates the space join, but the comma is the only delimiter that is correct for both. Join the boundary clauses with ', ' instead of a space. Also: - Drop the stray trailing comma in the version_boundaries() call. - Fix the untemplated docstring, which describes the opposite of the code: untemplated = True (the default) resolves the macros, untemplated = False keeps them as written. Tests written by AI. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
This commit is contained in:
parent
a5885283d0
commit
c23a2e4ab2
2 changed files with 8 additions and 8 deletions
|
|
@ -147,9 +147,9 @@ class Dependency: # export
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Render the dependency as a version constraint string.
|
"""Render the dependency as a version constraint string.
|
||||||
|
|
||||||
NAMES_ONLY renders the name alone. untemplated keeps the
|
NAMES_ONLY renders the name alone. With untemplated = False the
|
||||||
VERSION, VERSION-REVISION and REVISION macros as written instead
|
VERSION, VERSION-REVISION and REVISION macros are kept as
|
||||||
of the resolved versions. include_revision = False drops the
|
written instead of resolved. include_revision = False drops the
|
||||||
revision of VERSION specs. as_range expands a boundary that
|
revision of VERSION specs. as_range expands a boundary that
|
||||||
pins a full version into the range it spans. no_subpackages
|
pins a full version into the range it spans. no_subpackages
|
||||||
renders the base name, quote wraps the result in the given
|
renders the base name, quote wraps the result in the given
|
||||||
|
|
@ -161,12 +161,12 @@ class Dependency: # export
|
||||||
if syntax is Syntax.NAMES_ONLY:
|
if syntax is Syntax.NAMES_ONLY:
|
||||||
return name
|
return name
|
||||||
ret: list[str] = []
|
ret: list[str] = []
|
||||||
for boundary in self.version_boundaries(expanded = as_range, ):
|
for boundary in self.version_boundaries(expanded = as_range):
|
||||||
op = boundary.format_op(syntax)
|
op = boundary.format_op(syntax)
|
||||||
version = boundary.version.id(untemplated, include_revision)
|
version = boundary.version.id(untemplated, include_revision)
|
||||||
ret.append(f'{name} {op} {version}')
|
ret.append(f'{name} {op} {version}')
|
||||||
if ret:
|
if ret:
|
||||||
return ' '.join(ret)
|
return ', '.join(ret)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
return __str() if quote is None else f'{quote}{__str()}{quote}'
|
return __str() if quote is None else f'{quote}{__str()}{quote}'
|
||||||
|
|
|
||||||
|
|
@ -122,15 +122,15 @@ constraint = d.constraint_str(untemplated = False, as_range = True)
|
||||||
assert constraint == 'foo = VERSION-REVISION'
|
assert constraint == 'foo = VERSION-REVISION'
|
||||||
# A full version stays exact; a non-full one expands
|
# A full version stays exact; a non-full one expands
|
||||||
d = Dependency('foo = VERSION', app.get_version)
|
d = Dependency('foo = VERSION', app.get_version)
|
||||||
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4'
|
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3, foo < 1.2.4'
|
||||||
d = Dependency('foo >= VERSION', app.get_version)
|
d = Dependency('foo >= VERSION', app.get_version)
|
||||||
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4'
|
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3, foo < 1.2.4'
|
||||||
# '<' and '<=' are not expanded
|
# '<' and '<=' are not expanded
|
||||||
d = Dependency('foo <= VERSION', app.get_version)
|
d = Dependency('foo <= VERSION', app.get_version)
|
||||||
assert d.constraint_str(as_range = True) == 'foo <= 1.2.3'
|
assert d.constraint_str(as_range = True) == 'foo <= 1.2.3'
|
||||||
# The bound steps a micro, so a tripartite core expands
|
# The bound steps a micro, so a tripartite core expands
|
||||||
d = Dependency('foo = 1.2.3', app.get_version)
|
d = Dependency('foo = 1.2.3', app.get_version)
|
||||||
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3 foo < 1.2.4'
|
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3, foo < 1.2.4'
|
||||||
# Default syntax is SEM_VER
|
# Default syntax is SEM_VER
|
||||||
d = Dependency('foo < 2.0')
|
d = Dependency('foo < 2.0')
|
||||||
assert d.constraint_str(untemplated = False) == 'foo < 2.0'
|
assert d.constraint_str(untemplated = False) == 'foo < 2.0'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue