Added support for setting git version externally#170
Conversation
a09ac82 to
f85ae9d
Compare
|
I'd rather make override the whole How about something like this: if (NOT "${TINI_VERSION_GIT}" STREQUAL "")
# Version was set by the user directly
set(tini_VERSION_GIT " - ${TINI_VERSION_GIT}")
else()
# Extract git version and dirty-ness
execute_process (
COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
RESULT_VARIABLE git_version_check_ret
OUTPUT_VARIABLE tini_VERSION_GIT
)
execute_process(
COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE git_dirty_check_out
)
if("${git_version_check_ret}" EQUAL 0)
set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
if(NOT "${git_dirty_check_out}" STREQUAL "")
set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
endif()
else()
set(tini_VERSION_GIT "")
endif()
endif()
|
* This to help when building from source snapshots that don't have the .git file structure.
f85ae9d to
31b0908
Compare
|
I was trying for a minimal diff, But it looks like you wouldn't mind more if it was better. The intention of the patch is to facilitate the same build output (In this case the version string) when building a source snapshot. (like https://github.com/krallin/tini/archive/v0.19.0.tar.gz as it will produce a different version since the git commands will fail) |
This to help when building from source snapshots that typically don't have an entire repository.