Skip to content

Instantly share code, notes, and snippets.

@3F
Created April 19, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3F/e0d88d4d5c90df1e9a96 to your computer and use it in GitHub Desktop.
Save 3F/e0d88d4d5c90df1e9a96 to your computer and use it in GitHub Desktop.
Deprecated example of how to update revision with data from SCM - git
: Deprecated example of how to update revision with data from SCM - git
: format output: C++ preprocessor directives - #define (macro definitions)
@echo off
: Result into
set fout=revision.h
: Get data
: rev count
FOR /F %%i IN ('git rev-list HEAD --count') DO set git_rev_count=%%i
: rev SHA1 short
FOR /F %%i IN ('git rev-parse --short HEAD') DO set git_rev_sha1=%%i
: branch name
FOR /F %%i IN ('git rev-parse --abbrev-ref HEAD') DO set git_branch_name=%%i
: Format line
set dataString=%git_rev_count% [%git_branch_name% - %git_rev_sha1%]
: Result
echo // generated by a tool > %fout%
echo #ifndef REVISION_H >> %fout%
echo #define BASE 12771 >> %fout%
echo #ifdef _DEBUG >> %fout%
echo #define REVISION_STR "%dataString%(debug)" >> %fout%
echo #define L_REVISION_STR L"%dataString%(debug)" >> %fout%
echo #else >> %fout%
echo #define REVISION_STR "%dataString%" >> %fout%
echo #define L_REVISION_STR L"%dataString%" >> %fout%
echo #endif >> %fout%
echo #endif >> %fout%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment