Adaption of CTest-Scripts for Mercurial

This commit is contained in:
Bernhard F.W. Gschaider 2015-08-18 15:51:41 +02:00 committed by Hrvoje Jasak
parent 3944983064
commit 403fda0869
2 changed files with 84 additions and 16 deletions

View file

@ -165,10 +165,42 @@ elseif(GIT_FOUND)
SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
SET(BUILDNAME "${BUILDNAME}-git-rev=${GIT_REV_NUMBER}")
else()
# Not a git repository: no branch nor revision information available
execute_process(
COMMAND hg id
WORKING_DIRECTORY ${FOAM_ROOT}
OUTPUT_VARIABLE HG_STATUS
RESULT_VARIABLE HG_ECODE
ERROR_QUIET
)
if(NOT HG_ECODE)
# We have a valid git repository. Grab the branch and revision info.
# Add to the build name
message("No git-branch. Mercurial?")
EXEC_PROGRAM(hg
ARGS id --bookmarks
OUTPUT_VARIABLE GIT_BRANCH_NAME
)
EXEC_PROGRAM(hg
ARGS id --id
OUTPUT_VARIABLE GIT_REV_NUMBER
)
EXEC_PROGRAM(hg
ARGS log --template='git_{gitnode|short}' -l 1
OUTPUT_VARIABLE GIT_REAL_REV_NUMBER
)
string(REPLACE " " "_" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
string(REPLACE "+" ":modified" GIT_REV_NUMBER ${GIT_REV_NUMBER})
SET(GIT_REV_NUMBER "${GIT_REV_NUMBER}_${GIT_REAL_REV_NUMBER}")
message("Git branch (mercurial): ${GIT_BRANCH_NAME} Revision: ${GIT_REV_NUMBER}")
SET(BUILDNAME "${BUILDNAME}-hg-branch=${GIT_BRANCH_NAME}")
SET(BUILDNAME "${BUILDNAME}-hg-rev=${GIT_REV_NUMBER}")
else()
# Not a git or mercurial repository: no branch nor revision information available
SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
SET(BUILDNAME "${BUILDNAME}-git-rev=unknown")
endif()
endif()
else()
# Git is not available: no branch nor revision information supplied
SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
@ -182,6 +214,8 @@ string(REPLACE " " "_" BUILDNAME ${BUILDNAME})
string(REPLACE "/" "_" SITE ${SITE})
string(REPLACE " " "_" SITE ${SITE})
message("Build name: ${BUILDNAME}")
# Build section
#-----------------------------------------------------------------------------

View file

@ -165,10 +165,42 @@ elseif(GIT_FOUND)
SET(BUILDNAME "${BUILDNAME}-git-branch=${GIT_BRANCH_NAME}")
SET(BUILDNAME "${BUILDNAME}-git-rev=${GIT_REV_NUMBER}")
else()
# Not a git repository: no branch nor revision information available
execute_process(
COMMAND hg id
WORKING_DIRECTORY ${FOAM_ROOT}
OUTPUT_VARIABLE HG_STATUS
RESULT_VARIABLE HG_ECODE
ERROR_QUIET
)
if(NOT HG_ECODE)
# We have a valid git repository. Grab the branch and revision info.
# Add to the build name
message("No git-branch. Mercurial?")
EXEC_PROGRAM(hg
ARGS id --bookmarks
OUTPUT_VARIABLE GIT_BRANCH_NAME
)
EXEC_PROGRAM(hg
ARGS id --id
OUTPUT_VARIABLE GIT_REV_NUMBER
)
EXEC_PROGRAM(hg
ARGS log --template='git_{gitnode|short}' -l 1
OUTPUT_VARIABLE GIT_REAL_REV_NUMBER
)
string(REPLACE " " "_" GIT_BRANCH_NAME ${GIT_BRANCH_NAME})
string(REPLACE "+" ":modified" GIT_REV_NUMBER ${GIT_REV_NUMBER})
SET(GIT_REV_NUMBER "${GIT_REV_NUMBER}_${GIT_REAL_REV_NUMBER}")
message("Git branch (mercurial): ${GIT_BRANCH_NAME} Revision: ${GIT_REV_NUMBER}")
SET(BUILDNAME "${BUILDNAME}-hg-branch=${GIT_BRANCH_NAME}")
SET(BUILDNAME "${BUILDNAME}-hg-rev=${GIT_REV_NUMBER}")
else()
# Not a git or mercurial repository: no branch nor revision information available
SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
SET(BUILDNAME "${BUILDNAME}-git-rev=unknown")
endif()
endif()
else()
# Git is not available: no branch nor revision information supplied
SET(BUILDNAME "${BUILDNAME}-git-branch=unknown")
@ -182,6 +214,8 @@ string(REPLACE " " "_" BUILDNAME ${BUILDNAME})
string(REPLACE "/" "_" SITE ${SITE})
string(REPLACE " " "_" SITE ${SITE})
message("Build name: ${BUILDNAME}")
# Build section
#-----------------------------------------------------------------------------