diff --git a/README.adoc b/README.adoc index d9c11f7..2bf4612 100644 --- a/README.adoc +++ b/README.adoc @@ -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/.sh`. diff --git a/elixir/query.py b/elixir/query.py index f4e9845..2e24448 100755 --- a/elixir/query.py +++ b/elixir/query.py @@ -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': diff --git a/projects/amazon-freertos.sh b/projects/amazon-freertos.sh index 582a563..284a2cc 100644 --- a/projects/amazon-freertos.sh +++ b/projects/amazon-freertos.sh @@ -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 } diff --git a/projects/bluez.sh b/projects/bluez.sh index a7f5049..3613a70 100644 --- a/projects/bluez.sh +++ b/projects/bluez.sh @@ -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 } diff --git a/projects/llvm.sh b/projects/llvm.sh index 1fcaaef..a6c7616 100644 --- a/projects/llvm.sh +++ b/projects/llvm.sh @@ -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 } diff --git a/projects/mesa.sh b/projects/mesa.sh index 230331e..52cee0b 100644 --- a/projects/mesa.sh +++ b/projects/mesa.sh @@ -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 } diff --git a/projects/op-tee.sh b/projects/op-tee.sh index d7c543d..8937cd6 100644 --- a/projects/op-tee.sh +++ b/projects/op-tee.sh @@ -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 } diff --git a/projects/zephyr.sh b/projects/zephyr.sh index b3c45fa..149b385 100644 --- a/projects/zephyr.sh +++ b/projects/zephyr.sh @@ -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 } diff --git a/samples/projects/linuxtest.sh b/samples/projects/linuxtest.sh index bc875ba..7c1c5c0 100644 --- a/samples/projects/linuxtest.sh +++ b/samples/projects/linuxtest.sh @@ -11,7 +11,7 @@ list_tags_h() echo "v5 v5.6 v5.6.1" } -get_latest() +get_latest_tags() { echo "v5.6.1" } diff --git a/script.sh b/script.sh index 011e095..1446777 100755 --- a/script.sh +++ b/script.sh @@ -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)