Set repository, if possible.
This commit is contained in:
parent
b81a440b7c
commit
20540cc61b
|
|
@ -83,6 +83,7 @@ MESSAGE(STATUS "Commit Nr: Configuration.h: ${PROJECT_VERSION_COMMIT} Tag: ${CMA
|
|||
MESSAGE(STATUS "These tag values will override Configuration.h")
|
||||
SET(PROJECT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${PROJECT_VER_TAG_FLV})
|
||||
SET(PROJECT_VERSION_COMMIT ${CMAKE_MATCH_6})
|
||||
git_get_repository(PROJECT_REPOSITORY)
|
||||
else(GIT_FOUND)
|
||||
if (NO_TAG_IS_FATAL)
|
||||
MESSAGE(FATAL_ERROR "Git was not found or an error occurred parsing the tag. This is a fatal error according to the settings.")
|
||||
|
|
|
|||
|
|
@ -388,3 +388,34 @@ function(git_head_commit_number _var)
|
|||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_repository _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"Unknown"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" ls-remote --get-url
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX MATCH "([A-z0-9\-]+)/Prusa-Firmware.git" out "${out}")
|
||||
if("${CMAKE_MATCH_COUNT}" EQUAL 1)
|
||||
message("Found repository name ${CMAKE_MATCH_1}")
|
||||
set(${_var}
|
||||
"${CMAKE_MATCH_1}"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
message("Failed to get repository information")
|
||||
set(${_var}
|
||||
#"${out}" #outputs the github repo user name
|
||||
"Unknown" #All other repos shown as unknown
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
|||
Loading…
Reference in New Issue