0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 14:42:31 +00:00

Use temporary file for commit date check. ()

This commit is contained in:
Austin S. Hemmelgarn 2024-10-01 06:50:43 -04:00 committed by GitHub
parent ff8feb3f74
commit 3c91cb0066
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -532,6 +532,8 @@ get_netdata_latest_tag() {
newer_commit_date() {
info "Checking if a newer version of the updater script is available."
ndtmpdir="$(create_tmp_directory)"
commit_check_file="${ndtmpdir}/latest-commit.json"
commit_check_url="https://api.github.com/repos/netdata/netdata/commits?path=packaging%2Finstaller%2Fnetdata-updater.sh&page=1&per_page=1"
python_version_check="
from __future__ import print_function
@ -545,12 +547,14 @@ else:
print(data[0]['commit']['committer']['date'] if isinstance(data, list) and data else '')
"
_safe_download "${commit_check_url}" "${commit_check_file}"
if command -v jq > /dev/null 2>&1; then
commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | jq '.[0].commit.committer.date' 2>/dev/null | tr -d '"')"
commit_date="$(jq '.[0].commit.committer.date' 2>/dev/null < "${commit_check_file}" | tr -d '"')"
elif command -v python > /dev/null 2>&1;then
commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | python -c "${python_version_check}")"
commit_date="$(python -c "${python_version_check}" < "${commit_check_file}")"
elif command -v python3 > /dev/null 2>&1;then
commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | python3 -c "${python_version_check}")"
commit_date="$(python3 -c "${python_version_check}" < "${commit_check_file}")"
fi
if [ -z "${commit_date}" ] ; then