added version information to sentry and the about page
This commit is contained in:
parent
97c9c7ecb7
commit
4fb1230163
7 changed files with 42 additions and 2 deletions
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import subprocess
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _get_version():
|
||||
# first check for the environment variable that is set inside docker containers we build
|
||||
if version := os.environ.get('C3NAV_VERSION', None):
|
||||
return version.strip()
|
||||
|
||||
# alternatively check if there is a `.version` file at the root of the c3nav module
|
||||
version_file = Path(__file__).resolve().parent / '.version'
|
||||
with suppress(FileNotFoundError):
|
||||
if version := version_file.read_text().strip():
|
||||
return version
|
||||
|
||||
# last check if this a checkout of c3nav git repo and get the current HEAD
|
||||
if (Path(__file__).resolve().parent.parent.parent / '.git').exists():
|
||||
with suppress(FileNotFoundError, subprocess.SubprocessError):
|
||||
run = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True, encoding='utf-8')
|
||||
if run.returncode == 0:
|
||||
return run.stdout.strip()
|
||||
|
||||
# if everything fails return None
|
||||
return None
|
||||
|
||||
|
||||
__version__ = _get_version()
|
|
@ -13,6 +13,7 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from django.utils.crypto import get_random_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from c3nav import __version__ as c3nav_version
|
||||
from c3nav.utils.config import C3navConfigParser
|
||||
from c3nav.utils.environ import Env
|
||||
|
||||
|
@ -61,6 +62,7 @@ with suppress(ImportError):
|
|||
denylist = DEFAULT_DENYLIST + sensitive_env_vars + sensitive_vars
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
release=c3nav_version,
|
||||
integrations=[CeleryIntegration(), DjangoIntegration()],
|
||||
event_scrubber=EventScrubber(denylist=denylist),
|
||||
enable_tracing=bool(config.getfloat('sentry', 'traces_sample_rate', fallback=0.0)),
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
{% if patrons %}
|
||||
<p>{% blocktrans %}Development of the software was supported by the following patrons on <a href="https://patreon.com/c3nav" rel="external" target="_blank">Patreon</a>:{% endblocktrans %} {{ patrons }}</p>
|
||||
{% endif %}
|
||||
<p>Version: {{ version }}</p>
|
||||
|
||||
{% if address %}
|
||||
<h4>{% trans 'Responsible for this website:' %}</h4>
|
||||
|
|
|
@ -25,6 +25,7 @@ from django.views.decorators.cache import cache_control, never_cache
|
|||
from django.views.decorators.clickjacking import xframe_options_exempt
|
||||
from django.views.decorators.http import etag
|
||||
|
||||
from c3nav import __version__ as c3nav_version
|
||||
from c3nav.api.models import Secret
|
||||
from c3nav.control.forms import AccessPermissionForm, SignedPermissionDataError
|
||||
from c3nav.mapdata.grid import grid
|
||||
|
@ -362,6 +363,7 @@ def about_view(request):
|
|||
'patrons': settings.IMPRINT_PATRONS,
|
||||
'team': settings.IMPRINT_TEAM,
|
||||
'hosting': settings.IMPRINT_HOSTING,
|
||||
'version': c3nav_version,
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue