diff --git a/Utilities/git-version-gen.cmd b/Utilities/git-version-gen.cmd index f9155c26ca..3595ca3ef4 100644 --- a/Utilities/git-version-gen.cmd +++ b/Utilities/git-version-gen.cmd @@ -55,8 +55,18 @@ if errorlevel 1 ( goto done ) +rem // Get commit count from HEAD by default for /F %%I IN ('call %GIT% rev-list HEAD --count') do set GIT_VERSION=%%I -for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I + +rem // If we're in AppVeyor and we're building for master: Get commit count from unshallowed upstream +if defined APPVEYOR ( + if not defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ( + call %GIT% remote add upstream https://github.com/RPCS3/RPCS3.git + call %GIT% fetch --unshallow upstream + for /F %%I IN ('call %GIT% rev-list --count upstream/master') do set GIT_VERSION=%%I + ) +) + if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ( if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"=="master" ( for /f "tokens=1* delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set user=%%a @@ -69,6 +79,12 @@ if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ( for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I ) +rem // Get last commit (shortened) and concat after commit count in GIT_VERSION +for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I + +rem // Echo obtained GIT_VERSION for debug purposes if needed +echo %GIT_VERSION% + rem // Don't modify the file if it already has the current version. if exist "%GIT_VERSION_FILE%" ( findstr /C:"%GIT_VERSION%" "%GIT_VERSION_FILE%" > NUL