Allows to generate source code for your project's VCS (Version Control System) status.
Include this tool into your pre-build step to hardcode version strings.
To get a help use --help argument.
Generate C header file for Mercurial repository with temporary file.
hg summary > version.txt
vcsinfo --hg --c version.txt version.h
del version.txt
Note that you could omit both -hg and --c as it is defaults.
Generate C header file for Mercurial repository using pipes.
hg summary | vcsinfo > version.h
Generate C++ header file for Mercurial repository in v1.x compatibility mode.
hg summary | vcsinfo --cpp --compat version.h
Generate Java class for Git repository treating new files as modification.
git status | vcsinfo --git --java --package com.test --newismod > version.java
Generate C header for Subversion repository ignoring properties change.
svn info && svn status | vcsinfo --svn --noprops > version.h
// Version Information
// Generated by the VCS Information Tool v2.0 (c) Denis Andreev, Built Sep 8 2019 at 00:42:26
#define MERCURIAL_REVISION 23u
#define MERCURIAL_MODIFIED 1
#define MERCURIAL_HASH "6c784b7035ea"
#define MERCURIAL_BRANCH "default"
#define VCS_REVISION MERCURIAL_REVISION
#define VCS_MODIFIED MERCURIAL_MODIFIED
#define VCS_HASH MERCURIAL_HASH
#define VCS_BRANCH MERCURIAL_BRANCH