Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79932861
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
Thu, Aug 29, 01:10
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Aug 31, 01:10 (2 d)
Engine
blob
Format
Raw Data
Handle
20263204
Attached To
rTAMAAS tamaas
version.py
View Options
import
subprocess
import
base64
def
write_info_file
(
file_name
):
header
=
'''#include <string>\nstd::string tamaas_release_info = "'''
file_content
=
''
branch
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
])[:
-
1
]
commit
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
branch
])[:
-
1
]
file_content
+=
branch
+
' '
+
commit
+
'
\n\n
'
diff
=
subprocess
.
check_output
([
"git"
,
"diff"
])
diff_cached
=
subprocess
.
check_output
([
"git"
,
"diff"
,
"--cached"
])
file_content
+=
"diff
\n
"
+
base64
.
b64encode
(
diff
)
+
'
\n\n
'
file_content
+=
"diff --cached
\n
"
+
base64
.
b64encode
(
diff_cached
)
+
'
\n
'
remotes
=
subprocess
.
check_output
([
'git'
,
'remote'
,
'-v'
])
file_content
+=
"remotes
\n
"
+
remotes
+
'
\n
'
try
:
origin_branch_commit
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"origin/"
+
branch
])
file_content
+=
"origin/"
+
branch
+
" commit: "
+
origin_branch_commit
except
:
file_content
+=
"origin/"
+
branch
+
" does not exist"
file_content
+=
'"'
file_content
=
file_content
.
replace
(
'
\n
'
,
'
\\\n
'
)
with
open
(
file_name
,
'w'
)
as
file
:
file
.
write
(
header
+
file_content
+
';
\n
'
)
Event Timeline
Log In to Comment