lib.version.Version.__resolved_id(): Resolve VERSION to core
__resolved_id() returns the full version if only VERSION was specified, fix that. Also: raise Version.Error instead of a bare Exception. Tests written by AI. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
149739cc93
commit
f689e4ba94
2 changed files with 21 additions and 15 deletions
|
|
@ -38,11 +38,17 @@ class Version: # export
|
|||
raise Version.Error(
|
||||
f'Tried to look up version of {self.base_name} without lookup function'
|
||||
)
|
||||
version = self.__lookup_version(self.base_name)
|
||||
if self.__spec == 'REVISION':
|
||||
parts = version.split('-', 1)
|
||||
return parts[1] if len(parts) == 2 else ''
|
||||
return version
|
||||
resolved = self.__lookup_version(self.base_name)
|
||||
if self.__spec == 'VERSION-REVISION':
|
||||
return resolved
|
||||
parts = resolved.split('-')
|
||||
match self.__spec:
|
||||
case 'VERSION':
|
||||
return parts[0]
|
||||
case 'REVISION':
|
||||
return parts[1] if len(parts) == 2 else ''
|
||||
case _:
|
||||
raise Version.Error(f'Invalid version specifier "{self.__spec}"')
|
||||
|
||||
def __id(self, untemplate: bool, throw: bool = True) -> str:
|
||||
if not untemplate:
|
||||
|
|
@ -145,8 +151,8 @@ class Version: # export
|
|||
|
||||
def id(self, untemplate: bool, include_revision: bool = True) -> str:
|
||||
"""Return the version id: the raw spec if untemplate is False,
|
||||
else the resolved version. With include_revision = False a
|
||||
VERSION spec yields the core version.
|
||||
else the resolved version. A VERSION spec yields the core
|
||||
version.
|
||||
"""
|
||||
if not include_revision and self.__spec == 'VERSION':
|
||||
return self.core(untemplate)
|
||||
|
|
|
|||
Loading…
Reference in a new issue