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 #! \param source_dir The directory containing a working copy
15 #! \param prefix A prefix to prepent to the variables containing
16 #! the extracted information
21 message(FATAL_ERROR
"prefix argument not specified")
25 set(_wc_description
"NO TAG FOUND")
26 set(_dirty_repo_str " [local changes]")
33 execute_process(COMMAND ${GIT_EXECUTABLE} describe --exact-match --dirty=${_dirty_repo_str}
34 WORKING_DIRECTORY ${source_dir}
35 OUTPUT_VARIABLE _project_git_tagname
36 RESULT_VARIABLE _proper_version
37 ERROR_VARIABLE _description_error )
38 if(_proper_version EQUAL 0 )
39 set(_wc_description ${_project_git_tagname})
41 else(_proper_version EQUAL 0)
42 # the execution failed, i.e. the HEAD has no tag,
43 # for fallback string: execute again but without the --exact-match
44 execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=${_dirty_repo_str}
45 WORKING_DIRECTORY ${source_dir}
46 OUTPUT_VARIABLE _wc_description
47 RESULT_VARIABLE _proper_version
48 ERROR_VARIABLE _description_error)
51 # remove newline at and of the string
52 string(STRIP
"${_wc_description}" _wc_description)
57 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)