query: fix Query.query('latest')

It seems that now self.db.vers.exists('') returns True for some
projects, perhaps following the change from bsddb3 to berkeleydb.

Modify the logic to always call `./script.sh get-latest` at least once.

Fixes: #349

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2024-11-15 15:57:28 +01:00
parent f7ed4e84fd
commit 3d81fa4e4e

View file

@ -110,18 +110,18 @@ class Query:
elif cmd == 'latest':
# Returns the tag considered as the latest one
previous = None
tag = ''
index = 0
# If we get the same tag twice, we are at the oldest one
while not self.db.vers.exists(tag) and previous != tag:
previous = tag
while True:
tag = decode(self.script('get-latest', str(index))).rstrip('\n')
index += 1
return tag
# tag == previous implies oldest tag, we return it anyway
if self.db.vers.exists(tag) or tag == previous:
return tag
previous = tag
index += 1
elif cmd == 'type':