Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60556773
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
Wed, May 1, 02:09
Size
1 KB
Mime Type
text/x-python
Expires
Fri, May 3, 02:09 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17373582
Attached To
rTAMAAS tamaas
version.py
View Options
import
subprocess
import
base64
from
functools
import
reduce
def
git
(
*
args
):
return
subprocess
.
check_output
([
"git"
]
+
args
)
def
write_info_file
(
file_name
):
header
=
'#include "tamaas_info.hh"
\n\n
'
file_content
=
''
branch
=
git
(
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
)[:
-
1
]
commit
=
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
=
git
(
"diff"
)
diff
+=
"|"
.
encode
(
'ascii'
)
+
git
(
"diff"
,
"--cached"
)
file_content
+=
\
'std::string tamaas::TamaasInfo::diff = "{}";
\n
'
.
format
(
base64
.
b64encode
(
diff
))
remotes
=
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
)
with
open
(
file_name
,
'w'
)
as
file
:
file
.
write
(
header
+
file_content
)
Event Timeline
Log In to Comment