From bf36e40f22cdefd36da9349a941ee819d06fd87e Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Fri, 14 Mar 2025 16:44:25 -0500 Subject: [PATCH] Align chart_version.sh with openstack-helm-infra This change makes it possible to use identical chart_version.sh script in both git repos openstack-helm and openstack-helm-infra. This is to prepare for the upcoming merger with openstack-helm-infra and to reduce the number of merge conflicts. Change-Id: I18414cb0e45c0b595ba332363ef089bfbf37c5c0 --- tools/chart_version.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/chart_version.sh b/tools/chart_version.sh index 17a35b3ac6..83a9166172 100755 --- a/tools/chart_version.sh +++ b/tools/chart_version.sh @@ -14,11 +14,19 @@ MAJOR=$(echo $BASE_VERSION | cut -d. -f1); MINOR=$(echo $BASE_VERSION | cut -d. -f2); if git show-ref --tags $BASE_VERSION --quiet; then + # if there is tag $BASE_VERSION, then we count the number of commits since the tag PATCH=$(git log --oneline ${BASE_VERSION}.. $CHART_DIR | wc -l) else + # if there is no tag $BASE_VERSION, then we count the number of commits since the beginning PATCH=$(git log --oneline $CHART_DIR | wc -l) fi -OSH_COMMIT_SHA=$(git rev-parse --short HEAD); -OSH_INFRA_COMMIT_SHA=$(cd ../openstack-helm-infra; git rev-parse --short HEAD); -echo "${MAJOR}.${MINOR}.${PATCH}+${OSH_COMMIT_SHA}-${OSH_INFRA_COMMIT_SHA}" +COMMIT_SHA=$(git rev-parse --short HEAD); +OSH_INFRA_COMMIT_SHA=$(cd ../openstack-helm-infra; git rev-parse --short HEAD); +if [[ ${COMMIT_SHA} = ${OSH_INFRA_COMMIT_SHA} ]]; then + BUILD_META=${COMMIT_SHA} +else + BUILD_META=${COMMIT_SHA}-${OSH_INFRA_COMMIT_SHA} +fi + +echo "${MAJOR}.${MINOR}.${PATCH}+${BUILD_META}"