Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61121672
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
Sat, May 4, 16:26
Size
1 KB
Mime Type
text/x-python
Expires
Mon, May 6, 16:26 (2 d)
Engine
blob
Format
Raw Data
Handle
17426883
Attached To
rTAMAAS tamaas
version.py
View Options
# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
subprocess
import
base64
def
git
(
*
args
):
"""Run a git command"""
try
:
return
subprocess
.
check_output
([
"git"
]
+
list
(
args
))
except
subprocess
.
CalledProcessError
:
return
""
def
get_git_subst
():
"""Get info about state of git repository"""
branch
=
git
(
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
)[:
-
1
]
commit
=
git
(
"rev-parse"
,
branch
)[:
-
1
]
diff
=
git
(
"diff"
)
diff
+=
"|"
.
encode
(
'ascii'
)
+
git
(
"diff"
,
"--cached"
)
remotes
=
git
(
'remote'
,
'-v'
)
if
remotes
!=
""
:
remotes_string
=
remotes
[:
-
1
]
.
replace
(
'
\n
'
,
'
\\\\
n'
)
else
:
remotes_string
=
'""'
return
{
'@commit@'
:
commit
,
'@branch@'
:
branch
,
'@diff@'
:
base64
.
b64encode
(
diff
),
'@remotes@'
:
remotes_string
,
}
Event Timeline
Log In to Comment