From d980e8b4066d3b268be7c246345732d31da1f7cf Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 6 Jun 2023 12:25:57 +0200 Subject: [PATCH] [SDK] Simplify SDK version --- buildscripts/pre-commit | 27 ++++++++----------- .../opentelemetry/sdk/version/version.h | 3 --- sdk/src/version/version.cc | 20 ++++++-------- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/buildscripts/pre-commit b/buildscripts/pre-commit index eb09e01c2c..c21f363b5a 100755 --- a/buildscripts/pre-commit +++ b/buildscripts/pre-commit @@ -10,7 +10,7 @@ if [[ ! -w "$(pwd)/sdk/src/version/version.cc" && ! -w "$(pwd)/api/include/open exit 1 fi -# format: "v..-+--g"" +# format: "v..-+--g" semver_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-([0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*))?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?-([0-9]+)-g([0-9|a-z]+)$" git_tag=$(git describe --tags --long 2>/dev/null) || true if [[ ! -z $git_tag ]] && [[ $git_tag =~ $semver_regex ]]; then @@ -22,7 +22,7 @@ if [[ ! -z $git_tag ]] && [[ $git_tag =~ $semver_regex ]]; then count_new_commits="${BASH_REMATCH[9]}" latest_commit_hash="${BASH_REMATCH[10]}" if [[ -z ${major} ]] || [[ -z ${minor} ]] || [[ -z ${patch} ]] || [[ -z ${count_new_commits} ]] || [[ -z ${latest_commit_hash} ]]; then - echo "Error: Incorrect tag format recevived. Exiting.." + echo "Error: Incorrect tag format received. Exiting.." exit 1 fi else @@ -38,9 +38,8 @@ if [[ -z ${latest_commit_hash} ]]; then exit 1 fi -branch="$(git rev-parse --abbrev-ref HEAD)" short_version="${major}.${minor}.${patch}" -full_version="${short_version}-${pre_release}-${build_metadata}-${count_new_commits}-${branch}-${latest_commit_hash}" +full_version="${short_version}-${pre_release}-${build_metadata}" # Update api version.h sed -i "/^\#define OPENTELEMETRY_VERSION /c\#define OPENTELEMETRY_VERSION \"${short_version}\"" "$(pwd)/api/include/opentelemetry/version.h" @@ -64,18 +63,14 @@ namespace sdk { namespace version { -const int major_version = ${major}; -const int minor_version = ${minor}; -const int patch_version = ${patch}; -const char *pre_release = "${pre_release}"; -const char *build_metadata = "${build_metadata}"; -const int count_new_commits = ${count_new_commits}; -const char *branch = "${branch}"; -const char *commit_hash = "${latest_commit_hash}"; -const char *short_version = "${short_version}"; -const char *full_version = - "${full_version}"; -const char *build_date = "$(date -u)"; +const int major_version = ${major}; +const int minor_version = ${minor}; +const int patch_version = ${patch}; +const char *pre_release = "${pre_release}"; +const char *build_metadata = "${build_metadata}"; +const char *short_version = "${short_version}"; +const char *full_version = "${full_version}"; +const char *build_date = "$(date -u)"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/version/version.h b/sdk/include/opentelemetry/sdk/version/version.h index 758805b19c..1c9c285f90 100644 --- a/sdk/include/opentelemetry/sdk/version/version.h +++ b/sdk/include/opentelemetry/sdk/version/version.h @@ -19,9 +19,6 @@ extern const int minor_version; extern const int patch_version; extern const char *pre_release; extern const char *build_metadata; -extern const int count_new_commits; -extern const char *branch; -extern const char *commit_hash; extern const char *short_version; extern const char *full_version; extern const char *build_date; diff --git a/sdk/src/version/version.cc b/sdk/src/version/version.cc index 6dfc299814..a658331f27 100644 --- a/sdk/src/version/version.cc +++ b/sdk/src/version/version.cc @@ -11,18 +11,14 @@ namespace sdk { namespace version { -const int major_version = 1; -const int minor_version = 9; -const int patch_version = 1; -const char *pre_release = "NONE"; -const char *build_metadata = "NONE"; -const int count_new_commits = 22; -const char *branch = "make_release_1.9.1"; -const char *commit_hash = "5592180d539b59c4e8293bc927f5a6431fcbacdf"; -const char *short_version = "1.9.1"; -const char *full_version = - "1.9.1-NONE-NONE-22-make_release_1.9.1-5592180d539b59c4e8293bc927f5a6431fcbacdf"; -const char *build_date = "Fri 26 May 2023 07:14:07 AM UTC"; +const int major_version = 1; +const int minor_version = 9; +const int patch_version = 1; +const char *pre_release = "NONE"; +const char *build_metadata = "NONE"; +const char *short_version = "1.9.1"; +const char *full_version = "1.9.1-NONE-NONE"; +const char *build_date = "Fri 26 May 2023 07:14:07 AM UTC"; } // namespace version } // namespace sdk OPENTELEMETRY_END_NAMESPACE