script/query: don't restrict ./script.sh get-latest to a single tag

`./script.sh get-latest <offset>` gets the full list of tags, filters
it, sorts it then returns a single result. On the Python side, it gets
the first one. If that works, it uses it, else it tries the second one,
etc.

That is a weird implementation: modify get-latest to return all tags so
that Python code only has to spawn a single subprocess.

Also, rename it from `get-latest` to `get-latest-tags`. This makes
things more explicit (what latest?) and also explicits that more than
one tag is required.

Also, argument 1 is supposed to be an offset.
No custom implementation of get_latest() did implement that.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2024-11-15 16:23:30 +01:00
parent 972fdd73e1
commit c6bc09ed10
10 changed files with 26 additions and 28 deletions

View file

@ -444,9 +444,9 @@ to customize the `list_tags_h` function.
You should also make sure that Elixir properly identifies
the most recent versions:
./script.sh get-latest
./script.sh get-latest-tags | head
If needed, customize the `get_latest()` function.
If needed, customize the `get_latest_tags()` function.
If you want to enable support for `compatible` properties in Devicetree files,
add `dts_comp_support=1` at the beginning of `projects/<projectname>.sh`.

View file

@ -110,18 +110,16 @@ class Query:
elif cmd == 'latest':
previous = None
index = 0
# Returns the latest tag that is included in the database.
# This excludes release candidates.
sorted_tags = self.scriptLines('get-latest-tags')
while True:
tag = decode(self.script('get-latest', str(index))).rstrip('\n')
# tag == previous implies oldest tag, we return it anyway
if self.db.vers.exists(tag) or tag == previous:
for tag in sorted_tags:
if self.db.vers.exists(tag):
return tag
previous = tag
index += 1
# return the oldest tag, even if it does not exist in the database
return sorted_tags[-1]
elif cmd == 'type':

View file

@ -14,7 +14,7 @@ list_tags_h()
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
}
get_latest()
get_latest_tags()
{
git tag | grep '^20' | sort -V | tail -n 1
git tag | grep '^20' | sort -Vr
}

View file

@ -13,7 +13,7 @@ list_tags_h()
sed -E 's/^([0-9]*)\.([0-9]*)$/v\1 v\1.\2 \1.\2/'
}
get_latest()
get_latest_tags()
{
git tag | grep '^[0-9]\.' | sort -V | tail -n 1
git tag | grep '^[0-9]\.' | sort -Vr
}

View file

@ -16,7 +16,7 @@ list_tags_h()
sed -r 's/^llvmorg-([0-9]*)\.([0-9]*)(.*)$/v\1 v\1.\2 llvmorg-\1.\2\3/'
}
get_latest()
get_latest_tags()
{
git tag | grep 'llvmorg' | grep -v init | sort -V | tail -n 1
git tag | grep 'llvmorg' | grep -v init | sort -Vr
}

View file

@ -15,7 +15,7 @@ list_tags_h()
sed -r 's/^mesa-([0-9]*)(\.[0-9]*)(.*)$/v\1 v\1\2 mesa-\1\2\3/'
}
get_latest()
get_latest_tags()
{
git tag | version_dir | grep ^mesa-[0-9]*[\.][0-9]* | grep -v '\-rc' | sort -V | tail -n 1
git tag | version_dir | grep ^mesa-[0-9]*[\.][0-9]* | grep -v '\-rc' | sort -Vr
}

View file

@ -14,7 +14,7 @@ list_tags()
grep '^[0-9]\.'
}
get_latest()
get_latest_tags()
{
git tag | grep '^[0-9]\.' | grep -v '\-rc' | sort -V | tail -n 1
git tag | grep '^[0-9]\.' | grep -v '\-rc' | sort -Vr
}

View file

@ -17,7 +17,7 @@ list_tags_h()
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
}
get_latest()
get_latest_tags()
{
git tag | grep -v '^zephyr-v' | version_dir | grep -v '\-rc' | sort -V | tail -n 1
git tag | grep -v '^zephyr-v' | version_dir | grep -v '\-rc' | sort -Vr
}

View file

@ -11,7 +11,7 @@ list_tags_h()
echo "v5 v5.6 v5.6.1"
}
get_latest()
get_latest_tags()
{
echo "v5.6.1"
}

View file

@ -63,9 +63,9 @@ list_tags_h()
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
}
get_latest()
get_latest_tags()
{
git tag | version_dir | grep -v '\-rc' | sort -V | tail -n $(($opt1 + 1)) | head -1
git tag | version_dir | grep -v '\-rc' | sort -Vr
}
get_type()
@ -247,8 +247,8 @@ case $cmd in
fi
;;
get-latest)
get_latest
get-latest-tags)
get_latest_tags
;;
get-type)