Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90367979
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
Fri, Nov 1, 00:48
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Nov 3, 00:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22063217
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