mirror of https://github.com/ecmwf/eccodes.git
ECC-1904: API function to get the git branch
This commit is contained in:
parent
14cdab4eb8
commit
837c9afc4e
|
@ -379,6 +379,15 @@ if( HAVE_FORTRAN AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortr
|
|||
ecbuild_add_fortran_flags("-fallow-argument-mismatch")
|
||||
endif()
|
||||
|
||||
if(GIT_FOUND AND NOT ${GIT_EXECUTABLE} STREQUAL "")
|
||||
ecbuild_info("Found git: ${GIT_EXECUTABLE} (found version \"${GIT_VERSION_STRING}\")")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE eccodes_GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" )
|
||||
ecbuild_info("ecCodes branch = ${eccodes_GIT_BRANCH}" )
|
||||
endif()
|
||||
|
||||
###############################################################################
|
||||
# contents
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ const char* codes_get_git_sha1()
|
|||
{
|
||||
return grib_get_git_sha1();
|
||||
}
|
||||
const char* codes_get_git_branch()
|
||||
{
|
||||
return grib_get_git_branch();
|
||||
}
|
||||
|
||||
const char* codes_get_package_name(void)
|
||||
{
|
||||
return grib_get_package_name();
|
||||
|
|
|
@ -1264,6 +1264,7 @@ long codes_get_api_version(void);
|
|||
*/
|
||||
const char* codes_get_git_sha1(void);
|
||||
|
||||
const char* codes_get_git_branch(void);
|
||||
const char* codes_get_build_date(void);
|
||||
|
||||
/**
|
||||
|
|
|
@ -942,6 +942,7 @@ int grib_optimize_decimal_factor(grib_accessor* a, const char* reference_value,
|
|||
|
||||
/* grib_api_version.cc */
|
||||
const char* grib_get_git_sha1(void);
|
||||
const char* grib_get_git_branch(void);
|
||||
const char* codes_get_build_date(void);
|
||||
|
||||
/* grib_bits_any_endian.cc */
|
||||
|
|
|
@ -1259,6 +1259,8 @@ long grib_get_api_version(void);
|
|||
*/
|
||||
const char* grib_get_git_sha1(void);
|
||||
|
||||
const char* grib_get_git_branch(void);
|
||||
|
||||
/**
|
||||
* Get the package name
|
||||
*
|
||||
|
|
|
@ -13,6 +13,12 @@ const char* grib_get_git_sha1(void)
|
|||
{
|
||||
return "@eccodes_GIT_SHA1@";
|
||||
}
|
||||
|
||||
const char* grib_get_git_branch(void)
|
||||
{
|
||||
return "@eccodes_GIT_BRANCH@";
|
||||
}
|
||||
|
||||
const char* codes_get_build_date(void)
|
||||
{
|
||||
return "@eccodes_BUILD_DATE@";
|
||||
|
|
|
@ -40,6 +40,7 @@ static void print_debug_info(grib_context* context)
|
|||
#ifdef HAVE_AEC
|
||||
aec = 1;
|
||||
#endif
|
||||
grib_context_log(context, GRIB_LOG_DEBUG, "Git branch: %s", grib_get_git_branch());
|
||||
grib_context_log(context, GRIB_LOG_DEBUG, "Git SHA1: %s", grib_get_git_sha1());
|
||||
grib_context_log(context, GRIB_LOG_DEBUG, "Build date: %s", codes_get_build_date());
|
||||
grib_context_log(context, GRIB_LOG_DEBUG, "Features:");
|
||||
|
|
Loading…
Reference in New Issue