Skip to content

Commit c7f7d7e

Browse files
committed
Fixes commit count on GIT-VERSION
AppVeyor: Fetches commit count from unshallowed upstream instead of fetching from HEAD (will always be 3 since we clone with depth of 3)
1 parent 2c19fdf commit c7f7d7e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Utilities/git-version-gen.cmd

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,18 @@ if errorlevel 1 (
5555
goto done
5656
)
5757

58+
rem // Get commit count from HEAD by default
5859
for /F %%I IN ('call %GIT% rev-list HEAD --count') do set GIT_VERSION=%%I
59-
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I
60+
61+
rem // If we're in AppVeyor and we're building for master: Get commit count from unshallowed upstream
62+
if defined APPVEYOR (
63+
if not defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH (
64+
call %GIT% remote add upstream https://github.com/RPCS3/RPCS3.git
65+
call %GIT% fetch --unshallow upstream
66+
for /F %%I IN ('call %GIT% rev-list --count upstream/master') do set GIT_VERSION=%%I
67+
)
68+
)
69+
6070
if defined APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH (
6171
if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%"=="master" (
6272
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 (
6979
for /F %%I IN ('call %GIT% rev-parse --abbrev-ref HEAD') do set GIT_BRANCH=%%I
7080
)
7181

82+
rem // Get last commit (shortened) and concat after commit count in GIT_VERSION
83+
for /F %%I IN ('call %GIT% rev-parse --short HEAD') do set GIT_VERSION=%GIT_VERSION%-%%I
84+
85+
rem // Echo obtained GIT_VERSION for debug purposes if needed
86+
echo %GIT_VERSION%
87+
7288
rem // Don't modify the file if it already has the current version.
7389
if exist "%GIT_VERSION_FILE%" (
7490
findstr /C:"%GIT_VERSION%" "%GIT_VERSION_FILE%" > NUL

0 commit comments

Comments
 (0)