Skip to content

Commit 90f6fa4

Browse files
dbortfacebook-github-bot
authored andcommitted
Fix install_flatc.sh version checking (#2402)
Summary: Pull Request resolved: #2402 Instead of looking at the latest git tag, look at the contents of a file in the repo. The old logic broke when upstream released a new version, but we were still pinned to the old version. This was functionally harmless, but printed a misleading message to users. Reviewed By: shoumikhin Differential Revision: D54863485 fbshipit-source-id: eaaf7ebc148224298f06ce7f8418efb159692f44
1 parent b830021 commit 90f6fa4

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

build/install_flatc.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,23 @@ readonly NC="\033[0m" # No Color
2626

2727
# Prints the flatbuffers version of the git submodule.
2828
print_flatbuffers_version(){
29-
pushd "${FLATBUFFERS_PATH}" > /dev/null
30-
git describe --tags "$(git rev-list --tags --max-count=1)" | sed 's/^v//'
31-
popd > /dev/null
29+
local version_file="${FLATBUFFERS_PATH}/package.json"
30+
local version
31+
# Extract the version from the first line like `"version": "23.5.26",`
32+
# First remove the final double quote, then remove everything
33+
# before the now-final double quote.
34+
version="$(
35+
grep '"version"\s*:' "${version_file}" \
36+
| head -1 \
37+
| sed -e 's/"[^"]*$//' \
38+
| sed -e 's/.*"//'
39+
)"
40+
if [[ ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
41+
echo "${version}"
42+
else
43+
echo "ERROR: Bad version '${version}'; could not find version in ${version_file}" >&2
44+
exit 1
45+
fi
3246
}
3347

3448
main() {

0 commit comments

Comments
 (0)