Skip to content

Commit

Permalink
Merge branch 'main' into support/3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Dec 4, 2023
2 parents b285c90 + 3e5df40 commit 8ee567c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
50 changes: 45 additions & 5 deletions code/.version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,81 @@
import inspect
import json
import os
import platform
from subprocess import PIPE, run as subprocess_run

# ################################################################################################################################
# ################################################################################################################################

# Cannot use built in __file__ because we are execfile'd
_file = inspect.currentframe().f_code.co_filename

# ################################################################################################################################
# ################################################################################################################################

# Prepare all the directories needed
curdir = os.path.dirname(os.path.abspath(_file))
release_info_dir = os.path.join(curdir, 'release-info')
git_repo_dir = os.path.abspath(os.path.join(release_info_dir, '..'))

# ################################################################################################################################
# ################################################################################################################################

#
# This is Zato version information
#
release = open(os.path.join(release_info_dir, 'release.json')).read()
release = json.loads(release)

# ################################################################################################################################
# ################################################################################################################################

platform_system = platform.system().lower()

is_windows = 'windows' in platform_system
is_linux = 'linux' in platform_system # noqa: E272

# ################################################################################################################################
# ################################################################################################################################

#
# This is last git commit ID.
#
# Make sure to use -C to specify the git directory instead of navigating to it directly;
# the latter may result in spurious pip errors, such as:
# "error in zato-agent setup command: Distribution contains no modules or packages for namespace package 'zato'"
#
git_command = ['git', 'rev-parse', '--short', 'HEAD']
git_command_date = ['git', 'log', '-1', '--pretty=%cd', '--date=format:%Y.%m.%d']
git_command_revision = ['git', 'rev-parse', '--short', 'HEAD']

try:
process = subprocess_run(git_command, stdout=PIPE, check=True)

revision = process.stdout
process_date = subprocess_run(git_command_date, stdout=PIPE, check=True)
date = process_date.stdout
date = date.decode('utf8')
date = date.strip()

process_revision = subprocess_run(git_command_revision, stdout=PIPE, check=True)
revision = process_revision.stdout
revision = revision.decode('utf8')
revision = revision.strip()

except Exception as e:
version = '3.2-nogit'

if is_windows:
suffix = 'windows'
elif is_linux:
suffix = 'linux'
else:
suffix = platform_system

version = f'3.2-nogit-{suffix}'
else:
version = '{}.{}+rev.{}'.format(release['major'], release['minor'], revision)

major = release['major']
minor = release['minor']

version = f'{major}.{minor}.{date}+rev.{revision}'

# ################################################################################################################################
# ################################################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% if connection == 'channel' %}
channels
{% else %}
outconns
outgoing connections
{% endif %}

{% endblock %}
Expand Down

0 comments on commit 8ee567c

Please sign in to comment.