Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 8cd30706 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

Merge branch 'feature-28' into develop

Get more information on my git branch
parents 263df96d dbbdb1a5
......@@ -31,14 +31,16 @@ if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/CamiTKVersion.h)
# the svn command itself
include(cmake/modules/macros/GetGitInfo.cmake)
get_git_info(${CMAKE_CURRENT_SOURCE_DIR})
set(CAMITK_VERSION_GIT ".${CAMITK_GIT_COMMIT_COUNT}")
set(CAMITK_SVN_SUBVERSION_FOUND "1")
set(CAMITK_VERSION_GIT ".${CAMITK_GIT_BRANCH}.${CAMITK_GIT_ABBREVIATED_HASH}")
set(CAMITK_GIT_FOUND "1")
set(CAMITK_GIT_HASH "${CAMITK_GIT_HASH}")
set(CAMITK_GIT_DATE "${CAMITK_GIT_COMMITER_DATE}")
else()
set(CAMITK_VERSION_GIT ".git")
set(CAMITK_SVN_SUBVERSION_FOUND "0")
set(CAMITK_GIT_FOUND "0")
endif()
else()
set(CAMITK_SVN_SUBVERSION_FOUND "0")
set(CAMITK_GIT_FOUND "0")
set(CAMITK_SOURCE_PACKAGE_VERSION "1")
endif()
......
......@@ -28,18 +28,18 @@ bool compiledFromPackageSource() {
return @CAMITK_SOURCE_PACKAGE_VERSION@;
}
/// if the SDK is compiled from the svn version, this function returns if more svn information are available
bool hasMoreSvnInformation() {
return @CAMITK_SVN_SUBVERSION_FOUND@;
/// if the SDK is compiled from the git version, this function returns if more git information are available
bool hasMoreGitInformation() {
return @CAMITK_GIT_FOUND@;
}
/// if the SDK is compiled from the svn version, this function returns the svn revision
std::string svnRevision() {
return "@CAMITK_SVN_WC_REVISION@";
/// if the SDK is compiled from the git version, this function returns the git complete hash
std::string gitHash() {
return "@CAMITK_GIT_HASH@";
}
/// if the SDK is compiled from the svn version, this function returns the date of the last modified SDK file (YYYY-MM-DD HH:MM:SS)
std::string svnDate() {
return "@CAMITK_SVN_DATE@";
/// if the SDK is compiled from the git version, this function returns the last commit date
std::string gitDate() {
return "@CAMITK_GIT_DATE@";
}
\ No newline at end of file
......@@ -63,9 +63,9 @@ int main(int argc, char *argv[]) {
if (compiledFromPackageSource())
std::cout << "Compiled using package source." << std::endl;
else {
std::cout << "Compiled using svn";
if (hasMoreSvnInformation()) { //Check if CAMITK_SVN_SUBVERSION_FOUND can be set to "1" otherwise we never get into this 'if'
std::cout << " Rev: " << svnRevision() << ", Date: " << svnDate() << std::endl;
std::cout << "Compiled using git";
if (hasMoreGitInformation()) { // Check if CAMITK_GIT_FOUND can be set to "1" otherwise we never get into this 'if'
std::cout << " Hash: " << gitHash() << ", Date: " << gitDate() << std::endl;
}
std::cout << "." << std::endl;
}
......
......@@ -12,20 +12,42 @@
#! \inparam dir (required) input directory path
#!
macro(get_git_info dir)
# the subversion commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated, Alex
# set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
# set(ENV{LC_ALL} C)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_ABBREVIATED_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_COMMITER_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT CAMITK_GIT_COMMIT_COUNT)
message(WARNING "Unable to find the commit number using git : ${GIT_EXECUTABLE}")
set(CAMITK_GIT_COMMIT_COUNT "unknown")
set(CAMITK_GIT_BRANCH "unknown")
set(CAMITK_GIT_HASH "unknown")
set(CAMITK_GIT_ABBREVIATED_HASH "unknown")
endif()
endmacro()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment