1 #! \brief Extract the version description from a local working copy 3 #! If the given repository is a git repository, the functions runs the 4 #! git rev-parse --exact-match HEAD command 6 #! Information provided is stored in ${prefix}_REVISION_DESC an is 8 #! \li The exact tag if the HEAD of the source-tree has a tag 9 #! \li the 'git describe' output, which is <latest-reachable-tag>-<#Commits>-g<SHORT-HASH> 11 #! In case the working copy contains local changes, the ${prefix}_REVISION_DESC strings will contain 12 #! a suffix [local changes]. 14 #! The revision description can be overridden by a ${prefix}_CUSTOM_REVISION_DESC variable. 16 #! \param source_dir The directory containing a working copy 17 #! \param prefix A prefix to prepent to the variables containing 18 #! the extracted information 23 message(FATAL_ERROR
"prefix argument not specified")
26 if(${prefix}_CUSTOM_REVISION_DESC)
27 set(_wc_description ${${prefix}_CUSTOM_REVISION_DESC})
30 set(_wc_description
"NO TAG FOUND")
31 set(_dirty_repo_str
" [local changes]")
38 execute_process(COMMAND ${GIT_EXECUTABLE} describe --exact-match --dirty=${_dirty_repo_str}
39 WORKING_DIRECTORY ${source_dir}
40 OUTPUT_VARIABLE _project_git_tagname
41 RESULT_VARIABLE _proper_version
42 ERROR_VARIABLE _description_error )
43 if(_proper_version EQUAL 0 )
44 set(_wc_description ${_project_git_tagname})
45 else(_proper_version EQUAL 0)
46 # the execution failed, i.e. the HEAD has no tag, 47 # for fallback string: execute again but without the --exact-match 48 execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=${_dirty_repo_str}
49 WORKING_DIRECTORY ${source_dir}
50 OUTPUT_VARIABLE _wc_description
51 RESULT_VARIABLE _proper_version
52 ERROR_VARIABLE _description_error)
54 # remove newline at and of the string 55 string(STRIP
"${_wc_description}" _wc_description)
60 set(${prefix}_REVISION_DESC ${_wc_description} PARENT_SCOPE )
mitkFunctionGetVersionDescription(source_dir, prefix)
Extract the version description from a local working copy.
GIT_IS_REPO(dir, result_var)