From 917f7699f350925c18d70ee9269c313d62461081 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Wed, 3 May 2023 15:56:26 -0600 Subject: [PATCH] Use GitHub API to get commit count since the last ATS release --- infrastructure/cdn-in-a-box/bin/ats-version.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/infrastructure/cdn-in-a-box/bin/ats-version.sh b/infrastructure/cdn-in-a-box/bin/ats-version.sh index 9df0c5ff18..4be091c2a8 100755 --- a/infrastructure/cdn-in-a-box/bin/ats-version.sh +++ b/infrastructure/cdn-in-a-box/bin/ats-version.sh @@ -19,12 +19,14 @@ trap 'echo "Error on line ${LINENO} of ${0}" >/dev/stderr; exit 1' ERR; set -o errexit -o nounset -o pipefail +org=apache project=trafficserver script_dir="$(dirname "$0")" ats_version_file="${script_dir}/../cache/ATS_VERSION" remote_ats_version() { - local gitbox_url=https://gitbox.apache.org/repos/asf + local gitbox_url=https://gitbox.${org}.org/repos/asf + local github_api=https://api.github.com local repo="${project}.git" local branch refs commit last_tag release branch="$(grep 'ATS_VERSION=' "${script_dir}/../../../cache-config/testing/docker/variables.env" | cut -d= -f2)" @@ -40,8 +42,9 @@ remote_ats_version() { tail -n1)" # $release is the number of commits between $release to $branch. - page_output="$(curl -fs "${gitbox_url}?p=${repo};a=shortlog;h=${branch};hp=${last_tag}")" - release="$(<<<"$page_output" grep -c 'class="link"' || true)" + release="$(curl -fs "${github_api}/repos/${org}/${project}/compare/${last_tag}...${branch}" | + grep 'total_commits' | + grep -o '[0-9]\+')" <<<"${last_tag}-${release}.${commit:0:9}" tee "$ats_version_file" }