-
Notifications
You must be signed in to change notification settings - Fork 5
/
version_hack.sh
executable file
·30 lines (21 loc) · 840 Bytes
/
version_hack.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
#!/bin/sh
#package version
#
#const GitBranch = "PolarDBCCMGitBranch"
#const GitCommitId = "PolarDBCCMGitCommitId"
#const GitCommitDate = "PolarDBCCMGitCommitDate"
commit_id=$(git rev-parse HEAD)
echo "commitId: $commit_id"
commit_branch=$(git symbolic-ref --short -q HEAD)
echo "branch $commit_branch"
commit_date=$(git log -1 --format="%cd")
echo "git commit date: $commit_date"
gitrepo=$(git remote -v|grep origin|grep fetch|awk '{print $2}')
echo "git repo: $gitrepo"
rm -f version/version.go
echo "package version" > version/version.go
echo "" >>version/version.go
echo "const GitBranch = \"$commit_branch\"" >> version/version.go
echo "const GitCommitId = \"$commit_id\"" >> version/version.go
echo "const GitCommitDate = \"$commit_date\"" >> version/version.go
echo "const GitCommitRepo = \"$gitrepo\"" >> version/version.go