forked from arcemu/arcemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_version.sh
41 lines (35 loc) · 1.15 KB
/
git_version.sh
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
#!/bin/sh
branch=`git rev-parse --abbrev-ref HEAD`
version=`git log -1 --pretty=format:"%h"`
timestamp=`git log -1 --pretty=format:"%ct"`
commit_time=`git log -1 --pretty=format:"%ci"`
hostname=`hostname`
username=`whoami | cut -d\\\ -f2`
if [ -z "$version" ]
then
version="0"
fi
if [ -z "$timestamp" ]
then
timestamp="0"
fi
if [ -z "$commit_time" ]
then
commit_time="unknown commit time"
fi
if [ -z "$branch" ]
then
branch="unknown branch"
fi
echo "#ifndef GIT_VERSION_HPP" > src/shared/git_version.h
echo "#define GIT_VERSION_HPP" >> src/shared/git_version.h
echo "" >> src/shared/git_version.h
echo "#define BUILD_BRANCH \"$branch\"" >> src/shared/git_version.h
echo "#define BUILD_HASH 0x$version" >> src/shared/git_version.h
echo "#define COMMIT_TIMESTAMP $timestamp" >> src/shared/git_version.h
echo "#define COMMIT_TIME \"$commit_time\"" >> src/shared/git_version.h
echo "#define BUILD_HASH_STR \"$version\"" >> src/shared/git_version.h
echo "#define BUILD_USER_STR \"$username\"" >> src/shared/git_version.h
echo "#define BUILD_HOST_STR \"$hostname\"" >> src/shared/git_version.h
echo "" >> src/shared/git_version.h
echo "#endif" >> src/shared/git_version.h