In KBibTeX, there is a getgit.cmake file to collect information from Git regarding the source's history assuming that the source code came from a Git repository. ECMSourceVersionControl.cmake can be expanded making getgit.cmake's functionality available to all KDE projects.
Code from KBibTeX's getgit.cmake was refactored to fit ECMSourceVersionControl.cmake.
By loading this module, two variables will be set:
- A boolean variable ECM_SOURCE_UNDER_VERSION_CONTROL tells whether the current source directory is managed by a known version control system (VCS).
- String variable ECM_SOURCE_VERSION_CONTROL_WHICH contains an identifier which VCS is used, e.g. "git".
In case Git is used, functions ecm_source_version_control_probe_revision and ecm_source_version_control_probe_branch allow the retrieve the checkout's revision (8-character hex string) and branch (e.g. 'master'), respectively.
The documentation inserted at the beginning of the module explains the set variables and provided functions in greater detail.