-
Notifications
You must be signed in to change notification settings - Fork 9
/
get_git_log.py
38 lines (29 loc) · 926 Bytes
/
get_git_log.py
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
import os
import datetime
strGit = "#define PCO_GIT_VERSION \"$Id: PCO %s at [%s] $\"\n"
fnVersion = "./include/PcoGitVersion.h"
fnSdkLin="./sdkPco/PcoSdkVersion.h"
fnSdkWin="./sdkPcoLin/include/PcoSdkVersion.h"
fOut = open(fnVersion, "w")
log = os.popen('git log -n 1 --date=iso --format=format:"rev[%ad] head[%h][%H] ref[%d]" HEAD || echo "ERROR"').read()
dt = '{0:%Y/%m/%d %H:%M:%S}'.format(datetime.datetime.now())
line = strGit % (log, dt)
fOut.write(line)
try:
fIn = open(fnSdkLin, "r")
lines = fIn.readlines()
line = lines[0]
fIn.close()
except:
line = "#define PCO_SDK_LIN_VERSION \"$Id: PCOSDK_LIN [not defined] $\""
fOut.write(line)
try:
fIn = open(fnSdkWin, "r")
lines = fIn.readlines()
line = lines[0]
fIn.close()
except:
line = "#define PCO_SDK_WIN_VERSION \"$Id: PCOSDK_WIN [not defined] $\""
fOut.write(line)
line = strGit % (log, dt)
fOut.close()