In KBibTeX, there is a [[ https://cgit.kde.org/kbibtex.git/tree/src/getgit.cmake | `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` and similar code has been added to support Subversion and other version control systems.
The following information is extracted from version control systems:
* `ECM_SOURCE_VERSION_CONTROL_BRANCH` will contain the name of the branch, such as for example `master` for Git or `^/trunk` for Subversion
* `ECM_SOURCE_VERSION_CONTROL_REVISION` is the current revision, such as the SHA1 hash in Git or `r` followed by a number in Subversion
* `ECM_SOURCE_VERSION_CONTROL_COMMIT_COUNT` is the direct number of commits from the origin of the history until the current revisionBy loading this module, excluding any other branches.two variables will be set:
Different version control systems are supported to different degrees:
* Git is fully supported thanks to the mature code from `getgit.cmake`
* Subversion is well supported except for the question wheter to use `last-changed-revision` or just `revision` and how to correctly compute the commit count (some `svn log ... | grep -c ...` won't be available)* A boolean variable `ECM_SOURCE_UNDER_VERSION_CONTROL` tells whether the current source directory is managed by a known version control system (VCS).
* Mercurial support only covers `ECM_SOURCE_VERSION_CONTROL_BRANCH` but not `ECM_SOURCE_VERSION_CONTROL_COMMIT_COUNT` or `ECM_SOURCE_VERSION_CONTROL_REVISION`
* Bazaar is virtually incompleteString 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. However'master'), this seems to be a dead project anywayrespectively.
Due to its incomplete support, this revision requires input from people more familiar with Subversion, Mercurial, and BazaarThe documentation inserted at the beginning of the module explains the set variables and provided functions in greater detail.