forked from FreeCAD/FreeCAD-Bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_version_file.py
executable file
·41 lines (33 loc) · 1.34 KB
/
make_version_file.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
#!/usr/bin/env python
# call this file from within the FreeCAD git repo
# this script creates a file with the important version information
import os
import sys
import subprocess
sys.path.append(f"{os.getcwd()}/src/Tools")
import SubWCRev
gitInfo = SubWCRev.GitControl()
gitInfo.extractInfo("","")
i = open("src/Build/Version.h.cmake")
content = []
for line in i.readlines():
line = line.replace("${PACKAGE_WCREF}",gitInfo.rev)
line = line.replace("${PACKAGE_WCDATE}",gitInfo.date)
line = line.replace("${PACKAGE_WCURL}",gitInfo.url)
content.append(line)
with open("src/Build/Version.h.cmake", "w") as o:
content.append('// Git relevant stuff\n')
content.append('#define FCRepositoryHash "%s"\n' % (gitInfo.hash))
content.append('#define FCRepositoryBranch "%s"\n' % (gitInfo.branch))
o.writelines(content)
with open(os.sys.argv[1], "w") as f:
f.write(f"rev_number: {gitInfo.rev}\n")
f.write(f"branch_name: {gitInfo.branch}\n")
f.write(f"commit_date: {gitInfo.date}\n")
f.write(f"commit_hash: {gitInfo.hash}\n")
f.write(f"remote_url: {gitInfo.url}\n")
p = subprocess.Popen(["git", "-c", "user.name='ghaction'", "-c", "user.email='[email protected]'",
"commit", "-a", "-m", "add git information"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print(out.decode())
print(err.decode())