ECC-1904: API function to get the git branch

This commit is contained in:
shahramn 2024-08-15 13:06:58 +01:00
parent 837c9afc4e
commit 634134ea14
2 changed files with 8 additions and 2 deletions

View File

@ -383,6 +383,7 @@ if(GIT_FOUND AND NOT ${GIT_EXECUTABLE} STREQUAL "")
ecbuild_info("Found git: ${GIT_EXECUTABLE} (found version \"${GIT_VERSION_STRING}\")") ecbuild_info("Found git: ${GIT_EXECUTABLE} (found version \"${GIT_VERSION_STRING}\")")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE eccodes_GIT_BRANCH OUTPUT_VARIABLE eccodes_GIT_BRANCH
RESULT_VARIABLE nok ERROR_VARIABLE error
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" ) WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" )
ecbuild_info("ecCodes branch = ${eccodes_GIT_BRANCH}" ) ecbuild_info("ecCodes branch = ${eccodes_GIT_BRANCH}" )

View File

@ -40,8 +40,13 @@ static void print_debug_info(grib_context* context)
#ifdef HAVE_AEC #ifdef HAVE_AEC
aec = 1; aec = 1;
#endif #endif
grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", grib_get_git_branch()); const char* git_branch = grib_get_git_branch();
grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", grib_get_git_sha1()); const char* git_sha1 = grib_get_git_sha1();
if (strlen(git_branch) > 0)
grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", git_branch);
if (strlen(git_sha1) > 0)
grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", git_sha1);
grib_context_log(context, GRIB_LOG_DEBUG, "Build date: %s", codes_get_build_date()); grib_context_log(context, GRIB_LOG_DEBUG, "Build date: %s", codes_get_build_date());
grib_context_log(context, GRIB_LOG_DEBUG, "Features:"); grib_context_log(context, GRIB_LOG_DEBUG, "Features:");
grib_context_log(context, GRIB_LOG_DEBUG, " HAVE_AEC=%d", aec); grib_context_log(context, GRIB_LOG_DEBUG, " HAVE_AEC=%d", aec);