-
Notifications
You must be signed in to change notification settings - Fork 9
/
create_commit_def.py
47 lines (37 loc) · 1.61 KB
/
create_commit_def.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
39
40
41
42
43
44
45
46
47
import subprocess
import sys
if sys.platform.startswith("win"):
proc = subprocess.Popen('"C:\\Program Files\\Git\\bin\\git.exe" log -1 --name-status',
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
universal_newlines=True)
stdout, stderr = proc.communicate()
else:
proc = subprocess.Popen('git log -1 --name-status',
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
universal_newlines=True)
stdout, stderr = proc.communicate()
stdout = stdout.split('\n')[0].split()
assert stdout[0] == 'commit'
commit = stdout[1]
f = open('commit_def.py', 'w')
f.write('LATEST_COMMIT = "' + commit + '"\n')
f.close()
import os
os.chdir('cvlsshutils')
if sys.platform.startswith("win"):
proc = subprocess.Popen('"C:\\Program Files\\Git\\bin\\git.exe" log -1 --name-status',
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
universal_newlines=True)
stdout, stderr = proc.communicate()
else:
proc = subprocess.Popen('git log -1 --name-status',
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
universal_newlines=True)
stdout, stderr = proc.communicate()
stdout = stdout.split('\n')[0].split()
assert stdout[0] == 'commit'
commit = stdout[1]
os.chdir('..')
f = open('commit_def.py', 'a')
f.write('LATEST_COMMIT_CVLSSHUTILS = "' + commit + '"\n')
f.close()