Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122406783
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, Jul 17, 17:26
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Jul 19, 17:26 (2 d)
Engine
blob
Format
Raw Data
Handle
27439655
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
+=
'{} {}
\n\n
'
.
format
(
branch
,
commit
)
diff
=
subprocess
.
check_output
([
"git"
,
"diff"
])
diff_cached
=
subprocess
.
check_output
([
"git"
,
"diff"
,
"--cached"
])
file_content
+=
"diff
\n
{}
\n\n
"
.
format
(
base64
.
b64encode
(
diff
))
file_content
+=
"diff --cached
\n
{}
\n\n
"
.
format
(
base64
.
b64encode
(
diff_cached
))
remotes
=
subprocess
.
check_output
([
'git'
,
'remote'
,
'-v'
])
file_content
+=
"remotes
\n
{}
\n
"
.
format
(
remotes
)
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
)
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