mirror of
https://github.com/borgbackup/borg.git
synced 2026-05-23 02:25:33 -04:00
Apply suggested fix to src/borg/version.py from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
parent
a3d32f8846
commit
147b7ef348
1 changed files with 9 additions and 2 deletions
|
|
@ -38,12 +38,19 @@ def format_version(version):
|
|||
f = []
|
||||
it = iter(version)
|
||||
while True:
|
||||
part = next(it)
|
||||
try:
|
||||
part = next(it)
|
||||
except StopIteration:
|
||||
raise ValueError("Invalid version tuple %r" % (version,))
|
||||
if part >= 0:
|
||||
f.append(str(part))
|
||||
elif part == -1:
|
||||
break
|
||||
else:
|
||||
f[-1] = f[-1] + {-2: "rc", -3: "b", -4: "a", -9: ".dev"}[part] + str(next(it))
|
||||
try:
|
||||
pnum = next(it)
|
||||
except StopIteration:
|
||||
raise ValueError("Invalid prerelease version tuple %r" % (version,))
|
||||
f[-1] = f[-1] + {-2: "rc", -3: "b", -4: "a", -9: ".dev"}[part] + str(pnum)
|
||||
break
|
||||
return ".".join(f)
|
||||
|
|
|
|||
Loading…
Reference in a new issue