Fix branch name for AppVeyor Builds (#3472)

This commit is contained in:
Zion 2017-09-22 03:26:43 -07:00 committed by Ivan
parent c6e6f4afea
commit 8e66e719fa
1 changed files with 11 additions and 6 deletions

View File

@ -19,6 +19,8 @@ if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/../.git/")
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include version.") message(WARNING "git rev-parse failed, unable to include version.")
endif() endif()
# Hack fix for AppVeyor (Pull Requests don't generate a branch name)
if(NOT DEFINED ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH})
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOURCE_DIR} WORKING_DIRECTORY ${SOURCE_DIR}
RESULT_VARIABLE exit_code RESULT_VARIABLE exit_code
@ -26,6 +28,9 @@ if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/../.git/")
if(NOT ${exit_code} EQUAL 0) if(NOT ${exit_code} EQUAL 0)
message(WARNING "git rev-parse failed, unable to include git branch.") message(WARNING "git rev-parse failed, unable to include git branch.")
endif() endif()
else()
set(GIT_BRANCH $ENV{APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH})
endif()
string(STRIP ${GIT_VERSION} GIT_VERSION) string(STRIP ${GIT_VERSION} GIT_VERSION)
string(STRIP ${GIT_VERSION_} GIT_VERSION_) string(STRIP ${GIT_VERSION_} GIT_VERSION_)
string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION) string(STRIP ${GIT_VERSION}-${GIT_VERSION_} GIT_VERSION)