scmversion: Add date

This commit is contained in:
Connor McLaughlin 2020-08-20 00:43:07 +10:00
parent 71a38adbc7
commit e3e8e47ffc
3 changed files with 7 additions and 2 deletions

View file

@ -4,8 +4,9 @@ SET VERSIONFILE="scmversion.cpp"
FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse HEAD`) do (SET "HASH=%%g") FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse HEAD`) do (SET "HASH=%%g")
FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse --abbrev-ref HEAD`) do (SET "BRANCH=%%g") FOR /F "tokens=* USEBACKQ" %%g IN (`git rev-parse --abbrev-ref HEAD`) do (SET "BRANCH=%%g")
FOR /F "tokens=* USEBACKQ" %%g IN (`git describe --tags --dirty --exclude latest`) do (SET "TAG=%%g") FOR /F "tokens=* USEBACKQ" %%g IN (`git describe --tags --dirty --exclude latest`) do (SET "TAG=%%g")
FOR /F "tokens=* USEBACKQ" %%g IN (`git log -1 --date=iso8601-strict "--format=%%cd"`) do (SET "CDATE=%%g")
SET SIGNATURELINE=// %HASH% %BRANCH% %TAG% SET SIGNATURELINE=// %HASH% %BRANCH% %TAG% %CDATE%
SET /P EXISTINGLINE=< %VERSIONFILE% SET /P EXISTINGLINE=< %VERSIONFILE%
IF "%EXISTINGLINE%"=="%SIGNATURELINE%" ( IF "%EXISTINGLINE%"=="%SIGNATURELINE%" (
@ -19,6 +20,7 @@ ECHO Updating %VERSIONFILE%...
ECHO const char* g_scm_hash_str = "%HASH%"; ECHO const char* g_scm_hash_str = "%HASH%";
ECHO const char* g_scm_branch_str = "%BRANCH%"; ECHO const char* g_scm_branch_str = "%BRANCH%";
ECHO const char* g_scm_tag_str = "%TAG%"; ECHO const char* g_scm_tag_str = "%TAG%";
ECHO const char* g_scm_date_str = "%CDATE%";
)>%VERSIONFILE% )>%VERSIONFILE%
EXIT EXIT

View file

@ -4,8 +4,9 @@ VERSION_FILE="scmversion.cpp"
HASH=$(git rev-parse HEAD) HASH=$(git rev-parse HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD | tr -d '\r\n') BRANCH=$(git rev-parse --abbrev-ref HEAD | tr -d '\r\n')
TAG=$(git describe --tags --dirty --exclude latest | tr -d '\r\n') TAG=$(git describe --tags --dirty --exclude latest | tr -d '\r\n')
DATE=$(git log -1 --date=iso8601-strict --format=%cd)
SIGNATURE_LINE="// ${HASH} ${BRANCH} ${TAG}" SIGNATURE_LINE="// ${HASH} ${BRANCH} ${TAG} ${DATE}"
if [ -f $VERSION_FILE ]; then if [ -f $VERSION_FILE ]; then
EXISTING_LINE=$(head -n1 $VERSION_FILE | tr -d '\n') EXISTING_LINE=$(head -n1 $VERSION_FILE | tr -d '\n')
@ -22,6 +23,7 @@ ${SIGNATURE_LINE}
const char* g_scm_hash_str = "${HASH}"; const char* g_scm_hash_str = "${HASH}";
const char* g_scm_branch_str = "${BRANCH}"; const char* g_scm_branch_str = "${BRANCH}";
const char* g_scm_tag_str = "${TAG}"; const char* g_scm_tag_str = "${TAG}";
const char* g_scm_date_str = "${DATE}";
EOF EOF

View file

@ -3,4 +3,5 @@
extern const char* g_scm_hash_str; extern const char* g_scm_hash_str;
extern const char* g_scm_branch_str; extern const char* g_scm_branch_str;
extern const char* g_scm_tag_str; extern const char* g_scm_tag_str;
extern const char* g_scm_date_str;