forked from monash-merc/cvl-fabric-launcher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_commit_def.py
48 lines (38 loc) · 1.63 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
48
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
cwd = os.getcwd()
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(cwd)
f = open('commit_def.py', 'a')
f.write('LATEST_COMMIT_CVLSSHUTILS = "' + commit + '"\n')
f.close()