forked from LoneGazebo/Community-Patch-DLL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_commit_id.bat
More file actions
74 lines (60 loc) · 2.9 KB
/
update_commit_id.bat
File metadata and controls
74 lines (60 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@echo off
SETLOCAL EnableDelayedExpansion
REM ============================================================================
REM update_commit_id.bat - Generate version identifier from git repository
REM ============================================================================
REM This script generates commit_id.inc with CURRENT_GAMECORE_VERSION
REM Used to identify DLL version in crash dumps and debugging
REM ============================================================================
REM Check if git is available
where git >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo ERROR: git command not found. Cannot generate version identifier.
echo const char CURRENT_GAMECORE_VERSION[] = "Unknown - Git Not Found"; //autogenerated > "%~dp0commit_id.inc"
exit /b 1
)
REM Check working tree status
set STATUS=Clean
for /f "usebackq delims=" %%i in (`git status --untracked-files^=no --porcelain 2^>nul`) do (
if [%%i] NEQ [] (
set STATUS=Dirty
echo Uncommitted change^(s^): %%i
)
)
if "%STATUS%" == "Clean" (echo Nothing to commit, working tree clean.)
REM Get current commit hash (always available)
set HEADCOMMIT=
for /f "usebackq delims=" %%i in (`git rev-list --abbrev-commit -n 1 HEAD 2^>nul`) do set HEADCOMMIT=%%i
if "%HEADCOMMIT%" == "" (
echo ERROR: Could not determine HEAD commit. Not in a git repository?
echo const char CURRENT_GAMECORE_VERSION[] = "Unknown - Not Git Repo"; //autogenerated > "%~dp0commit_id.inc"
exit /b 1
)
REM Try to get tag information using git describe
set TAG=
set TAGCOMMIT=
set DESCRIBE_OUTPUT=
REM Use git describe --tags --long to ALWAYS include commit hash
REM --long forces format: tag-distance-ghash even when on exact tag
REM Example: Release-5.1.2-0-gb44ce57d (on tag) or Release-5.1.3-7-g2d10a8a (after tag)
for /f "usebackq delims=" %%i in (`git describe --tags --long HEAD 2^>nul`) do set DESCRIBE_OUTPUT=%%i
if "!DESCRIBE_OUTPUT!" == "" (
REM No tags found at all - use commit hash only
echo WARNING: No git tags found. Using commit hash only.
echo const char CURRENT_GAMECORE_VERSION[] = "No-Tag !HEADCOMMIT! !STATUS!"; //autogenerated, do not commit this file! > "%~dp0commit_id.inc"
echo Version identifier will be "No-Tag !HEADCOMMIT! !STATUS!"
goto :end
)
REM Parse git describe --long output
REM Format is ALWAYS: tag-distance-ghash
REM Release-5.1.2-0-gb44ce57d (exactly on tag, 0 commits after)
REM Release-5.1.3-7-g2d10a8aee (7 commits after tag)
echo Git describe output: !DESCRIBE_OUTPUT!
REM Use git describe --long output directly - always includes commit hash
REM Format is ALWAYS: tag-distance-ghash
REM "Release-5.1.2-0-gb44ce57d" (exactly on tag, hash b44ce57d)
REM "Release-5.1.3-7-g2d10a8aee" (7 commits after tag, hash 2d10a8aee)
echo const char CURRENT_GAMECORE_VERSION[] = "!DESCRIBE_OUTPUT! !STATUS!"; //autogenerated, do not commit this file! > "%~dp0commit_id.inc"
echo Version identifier will be "!DESCRIBE_OUTPUT! !STATUS!"
:end
ENDLOCAL