ScmRevGen: Set commits ahead to zero when on a tag
This commit is contained in:
parent
f49659fbfc
commit
35f383d9b0
|
@ -22,16 +22,17 @@ if(GIT_FOUND)
|
||||||
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^master
|
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^master
|
||||||
OUTPUT_VARIABLE DOLPHIN_WC_COMMITS_AHEAD_MASTER
|
OUTPUT_VARIABLE DOLPHIN_WC_COMMITS_AHEAD_MASTER
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
# defines DOLPHIN_WC_TAG
|
||||||
|
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --exact-match HEAD
|
||||||
|
OUTPUT_VARIABLE DOLPHIN_WC_TAG
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# version number
|
# version number
|
||||||
set(DOLPHIN_VERSION_MAJOR "5")
|
set(DOLPHIN_VERSION_MAJOR "5")
|
||||||
set(DOLPHIN_VERSION_MINOR "0")
|
set(DOLPHIN_VERSION_MINOR "0")
|
||||||
if(DOLPHIN_WC_BRANCH STREQUAL "stable")
|
set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
|
||||||
set(DOLPHIN_VERSION_PATCH "0")
|
|
||||||
else()
|
|
||||||
set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# If Dolphin is not built from a Git repository, default the version info to
|
# If Dolphin is not built from a Git repository, default the version info to
|
||||||
# reasonable values.
|
# reasonable values.
|
||||||
|
@ -42,6 +43,13 @@ if(NOT DOLPHIN_WC_REVISION)
|
||||||
set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
|
set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# If this is a tag (i.e. a release), then set the current patch version and
|
||||||
|
# the number of commits ahead to zero.
|
||||||
|
if(DOLPHIN_WC_TAG)
|
||||||
|
set(DOLPHIN_VERSION_PATCH "0")
|
||||||
|
set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
function(configure_source_file path)
|
function(configure_source_file path)
|
||||||
configure_file(
|
configure_file(
|
||||||
"${PROJECT_SOURCE_DIR}/${path}.in"
|
"${PROJECT_SOURCE_DIR}/${path}.in"
|
||||||
|
|
|
@ -6,6 +6,7 @@ var cmd_revision = " rev-parse HEAD";
|
||||||
var cmd_describe = " describe --always --long --dirty";
|
var cmd_describe = " describe --always --long --dirty";
|
||||||
var cmd_branch = " rev-parse --abbrev-ref HEAD";
|
var cmd_branch = " rev-parse --abbrev-ref HEAD";
|
||||||
var cmd_commits_ahead = " rev-list --count HEAD ^master";
|
var cmd_commits_ahead = " rev-list --count HEAD ^master";
|
||||||
|
var cmd_get_tag = " describe --exact-match HEAD";
|
||||||
|
|
||||||
function GetGitExe()
|
function GetGitExe()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +60,25 @@ function GetFirstStdOutLine(cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AttemptToExecuteCommand(cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var exec = wshShell.Exec(cmd)
|
||||||
|
|
||||||
|
// wait until the command has finished
|
||||||
|
while (exec.Status == 0) {}
|
||||||
|
|
||||||
|
return exec.ExitCode;
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
// catch "the system cannot find the file specified" error
|
||||||
|
WScript.Echo("Failed to exec " + cmd + " this should never happen");
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function GetFileContents(f)
|
function GetFileContents(f)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -88,6 +108,12 @@ if (default_update_track == "%DOLPHIN_DEFAULT_UPDATE_TRACK%") default_update_tra
|
||||||
// remove hash (and trailing "-0" if needed) from description
|
// remove hash (and trailing "-0" if needed) from description
|
||||||
describe = describe.replace(/(-0)?-[^-]+(-dirty)?$/, '$2');
|
describe = describe.replace(/(-0)?-[^-]+(-dirty)?$/, '$2');
|
||||||
|
|
||||||
|
// set commits ahead to zero if on a tag
|
||||||
|
if (AttemptToExecuteCommand(gitexe + cmd_get_tag) == 0)
|
||||||
|
{
|
||||||
|
commits_ahead = "0";
|
||||||
|
}
|
||||||
|
|
||||||
var out_contents =
|
var out_contents =
|
||||||
"#define SCM_REV_STR \"" + revision + "\"\n" +
|
"#define SCM_REV_STR \"" + revision + "\"\n" +
|
||||||
"#define SCM_DESC_STR \"" + describe + "\"\n" +
|
"#define SCM_DESC_STR \"" + describe + "\"\n" +
|
||||||
|
|
Loading…
Reference in New Issue