Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86703874
version.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 8, 03:22
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Oct 10, 03:22 (2 d)
Engine
blob
Format
Raw Data
Handle
21471208
Attached To
rTAMAAS tamaas
version.py
View Options
import
subprocess
import
base64
from
functools
import
reduce
def
write_info_file
(
file_name
):
header
=
'#include "tamaas_info.hh"
\n\n
'
file_content
=
''
branch
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
])[:
-
1
]
commit
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
branch
])[:
-
1
]
file_content
+=
'std::string tamaas::TamaasInfo::branch = "{}";
\n
'
.
format
(
branch
)
file_content
+=
'std::string tamaas::TamaasInfo::commit = "{}";
\n
'
.
format
(
commit
)
diff
=
subprocess
.
check_output
([
"git"
,
"diff"
])
diff
+=
"|"
.
encode
(
'ascii'
)
+
subprocess
.
check_output
([
"git"
,
"diff"
,
"--cached"
])
file_content
+=
'std::string tamaas::TamaasInfo::diff = "{}";
\n
'
.
format
(
base64
.
b64encode
(
diff
))
remotes
=
subprocess
.
check_output
([
'git'
,
'remote'
,
'-v'
])
remotes_strings
=
filter
(
lambda
x
:
x
!=
''
,
remotes
.
splitlines
())
remotes_string
=
reduce
(
lambda
x
,
y
:
x
+
'"{}
\\
n"
\n
'
.
format
(
y
),
remotes_strings
,
""
)
file_content
+=
'std::string tamaas::TamaasInfo::remotes = {};
\n
'
.
format
(
remotes_string
)
# try:
# origin_branch_commit = subprocess.check_output(["git", "rev-parse", "origin/" + branch, '--'], universal_newlines=True)
# file_content += "origin/{} commit: {}".format(branch, origin_branch_commit)
# except:
# file_content += "origin/ {} does not exist".format(branch)
with
open
(
file_name
,
'w'
)
as
file
:
file
.
write
(
header
+
file_content
)
Event Timeline
Log In to Comment