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:
parent
972fdd73e1
commit
c6bc09ed10
10 changed files with 26 additions and 28 deletions
|
|
@ -444,9 +444,9 @@ to customize the `list_tags_h` function.
|
||||||
You should also make sure that Elixir properly identifies
|
You should also make sure that Elixir properly identifies
|
||||||
the most recent versions:
|
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,
|
If you want to enable support for `compatible` properties in Devicetree files,
|
||||||
add `dts_comp_support=1` at the beginning of `projects/<projectname>.sh`.
|
add `dts_comp_support=1` at the beginning of `projects/<projectname>.sh`.
|
||||||
|
|
|
||||||
|
|
@ -110,18 +110,16 @@ class Query:
|
||||||
|
|
||||||
elif cmd == 'latest':
|
elif cmd == 'latest':
|
||||||
|
|
||||||
previous = None
|
# Returns the latest tag that is included in the database.
|
||||||
index = 0
|
# This excludes release candidates.
|
||||||
|
sorted_tags = self.scriptLines('get-latest-tags')
|
||||||
|
|
||||||
while True:
|
for tag in sorted_tags:
|
||||||
tag = decode(self.script('get-latest', str(index))).rstrip('\n')
|
if self.db.vers.exists(tag):
|
||||||
|
|
||||||
# tag == previous implies oldest tag, we return it anyway
|
|
||||||
if self.db.vers.exists(tag) or tag == previous:
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
previous = tag
|
# return the oldest tag, even if it does not exist in the database
|
||||||
index += 1
|
return sorted_tags[-1]
|
||||||
|
|
||||||
elif cmd == 'type':
|
elif cmd == 'type':
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ list_tags_h()
|
||||||
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ list_tags_h()
|
||||||
sed -E 's/^([0-9]*)\.([0-9]*)$/v\1 v\1.\2 \1.\2/'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ list_tags_h()
|
||||||
sed -r 's/^llvmorg-([0-9]*)\.([0-9]*)(.*)$/v\1 v\1.\2 llvmorg-\1.\2\3/'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ list_tags_h()
|
||||||
sed -r 's/^mesa-([0-9]*)(\.[0-9]*)(.*)$/v\1 v\1\2 mesa-\1\2\3/'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ list_tags()
|
||||||
grep '^[0-9]\.'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ list_tags_h()
|
||||||
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ list_tags_h()
|
||||||
echo "v5 v5.6 v5.6.1"
|
echo "v5 v5.6 v5.6.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_latest()
|
get_latest_tags()
|
||||||
{
|
{
|
||||||
echo "v5.6.1"
|
echo "v5.6.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ list_tags_h()
|
||||||
sed -r 's/^(v[0-9]*)\.([0-9]*)(.*)$/\1 \1.\2 \1.\2\3/'
|
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()
|
get_type()
|
||||||
|
|
@ -247,8 +247,8 @@ case $cmd in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
get-latest)
|
get-latest-tags)
|
||||||
get_latest
|
get_latest_tags
|
||||||
;;
|
;;
|
||||||
|
|
||||||
get-type)
|
get-type)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue