Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
3bc3ee20
Commit
3bc3ee20
authored
6 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
add version script
parent
6dd28874
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!23
WIP: Feature/use cmake
Pipeline
#45080
failed
6 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
get_version.py
+64
-0
64 additions, 0 deletions
get_version.py
with
64 additions
and
0 deletions
get_version.py
0 → 100644
+
64
−
0
View file @
3bc3ee20
#######################################################################
# #
# Copyright 2015-2019 Max Planck Institute #
# for Dynamics and Self-Organization #
# #
# This file is part of bfps. #
# #
# bfps is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published #
# by the Free Software Foundation, either version 3 of the License, #
# or (at your option) any later version. #
# #
# bfps 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with bfps. If not, see <http://www.gnu.org/licenses/> #
# #
# Contact: Cristian.Lalescu@ds.mpg.de #
# #
#######################################################################
import
datetime
import
subprocess
def
main
():
# get current time
now
=
datetime
.
datetime
.
now
()
# obtain version
try
:
git_branch
=
subprocess
.
check_output
([
'
git
'
,
'
rev-parse
'
,
'
--abbrev-ref
'
,
'
HEAD
'
]).
strip
().
split
()[
-
1
].
decode
()
git_revision
=
subprocess
.
check_output
([
'
git
'
,
'
rev-parse
'
,
'
HEAD
'
]).
strip
()
git_date
=
datetime
.
datetime
.
fromtimestamp
(
int
(
subprocess
.
check_output
([
'
git
'
,
'
log
'
,
'
-1
'
,
'
--format=%ct
'
]).
strip
()))
except
:
git_revision
=
''
git_branch
=
''
git_date
=
now
if
git_branch
==
''
:
# there's no git available or something
VERSION
=
'
{0:0>4}{1:0>2}{2:0>2}.{3:0>2}{4:0>2}{5:0>2}
'
.
format
(
git_date
.
year
,
git_date
.
month
,
git_date
.
day
,
git_date
.
hour
,
git_date
.
minute
,
git_date
.
second
)
else
:
VERSION
=
subprocess
.
check_output
([
'
git
'
,
'
describe
'
,
'
--tags
'
]).
strip
().
decode
().
split
(
'
-
'
)[
0
]
if
((
'
develop
'
in
git_branch
)
or
(
'
feature
'
in
git_branch
)
or
(
'
bugfix
'
in
git_branch
)):
VERSION_py
=
subprocess
.
check_output
(
[
'
git
'
,
'
describe
'
,
'
--tags
'
,
'
--dirty
'
]).
strip
().
decode
().
replace
(
'
-g
'
,
'
+g
'
).
replace
(
'
-dirty
'
,
'
.dirty
'
).
replace
(
'
-
'
,
'
.post
'
)
else
:
VERSION_py
=
VERSION
print
(
VERSION
)
return
VERSION_py
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment