Skip to content
Snippets Groups Projects
Commit f6a47be9 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

Feature/merge examples projects

parent 2ff9344a
Branches
Tags
1 merge request!86Feature/merge examples projects
...@@ -54,7 +54,7 @@ execute_process( ...@@ -54,7 +54,7 @@ execute_process(
OUTPUT_VARIABLE TURTLE_VERSION OUTPUT_VARIABLE TURTLE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version_long.py COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version.py --long
OUTPUT_VARIABLE TURTLE_VERSION_LONG OUTPUT_VARIABLE TURTLE_VERSION_LONG
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
......
File moved
...@@ -25,8 +25,16 @@ ...@@ -25,8 +25,16 @@
import datetime import datetime
import subprocess import subprocess
import argparse
def main(): def main():
parser = argparse.ArgumentParser('Get git version.')
parser.add_argument(
'-l',
'--long',
dest = 'long',
help = 'Request exact versioning information (including git hash).',
action = 'store_true')
# get current time # get current time
now = datetime.datetime.now() now = datetime.datetime.now()
# obtain version # obtain version
...@@ -46,18 +54,17 @@ def main(): ...@@ -46,18 +54,17 @@ def main():
VERSION = '{0:0>4}{1:0>2}{2:0>2}.{3:0>2}{4:0>2}{5:0>2}'.format( 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.year, git_date.month, git_date.day,
git_date.hour, git_date.minute, git_date.second) git_date.hour, git_date.minute, git_date.second)
VERSION_py = VERSION VERSION_long = VERSION
else: else:
VERSION = subprocess.check_output(['git', 'describe', '--tags']).strip().decode().split('-')[0] VERSION = subprocess.check_output(['git', 'describe', '--tags']).strip().decode().split('-')[0]
if (('develop' in git_branch) or VERSION_long = subprocess.check_output(
('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') ['git', 'describe', '--tags', '--dirty']).strip().decode().replace('-g', '+g').replace('-dirty', '.dirty').replace('-', '.post')
opt = parser.parse_args()
if opt.long:
print(VERSION_long)
else: else:
VERSION_py = VERSION
print(VERSION) print(VERSION)
return VERSION_py return VERSION_long
if __name__ == '__main__': if __name__ == '__main__':
main() main()
......
################################################################################
# #
# Copyright 2019 Max Planck Institute for Dynamics and Self-Organization #
# #
# This file is part of TurTLE. #
# #
# TurTLE 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. #
# #
# TurTLE 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 TurTLE. 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)
VERSION_py = VERSION
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_py)
return VERSION_py
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment