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.sh
More file actions
executable file
·64 lines (51 loc) · 2.46 KB
/
update_commit_id.sh
File metadata and controls
executable file
·64 lines (51 loc) · 2.46 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
#!/bin/bash
# ============================================================================
# update_commit_id.sh - Generate version identifier from git repository
# ============================================================================
# This script generates commit_id.inc with CURRENT_GAMECORE_VERSION
# Used to identify DLL version in crash dumps and debugging
# Linux/Mac equivalent of update_commit_id.bat
# ============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT_FILE="${SCRIPT_DIR}/commit_id.inc"
# Check if git is available
if ! command -v git &> /dev/null; then
echo "ERROR: git command not found. Cannot generate version identifier."
echo 'const char CURRENT_GAMECORE_VERSION[] = "Unknown - Git Not Found"; //autogenerated' > "$OUTPUT_FILE"
exit 1
fi
# Check working tree status
STATUS="Clean"
if [ -n "$(git status --untracked-files=no --porcelain 2>/dev/null)" ]; then
STATUS="Dirty"
echo "Uncommitted changes detected:"
git status --untracked-files=no --porcelain
fi
if [ "$STATUS" == "Clean" ]; then
echo "Nothing to commit, working tree clean."
fi
# Get current commit hash (always available)
HEADCOMMIT=$(git rev-list --abbrev-commit -n 1 HEAD 2>/dev/null)
if [ -z "$HEADCOMMIT" ]; then
echo "ERROR: Could not determine HEAD commit. Not in a git repository?"
echo 'const char CURRENT_GAMECORE_VERSION[] = "Unknown - Not Git Repo"; //autogenerated' > "$OUTPUT_FILE"
exit 1
fi
# Try to get tag information using git describe
DESCRIBE_OUTPUT=$(git describe --tags HEAD 2>/dev/null || true)
if [ -z "$DESCRIBE_OUTPUT" ]; then
# 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!" > "$OUTPUT_FILE"
echo "Version identifier will be \"No-Tag $HEADCOMMIT $STATUS\""
exit 0
fi
echo "Git describe output: $DESCRIBE_OUTPUT"
# Use git describe output directly - it contains all needed info
# Formats:
# "Release-5.1" (exactly on tag)
# "Release-5.1-3-gadd24e8ef" (3 commits after tag, at commit add24e8ef)
echo "const char CURRENT_GAMECORE_VERSION[] = \"$DESCRIBE_OUTPUT $STATUS\"; //autogenerated, do not commit this file!" > "$OUTPUT_FILE"
echo "Version identifier will be \"$DESCRIBE_OUTPUT $STATUS\""
echo "Generated $OUTPUT_FILE successfully."