riparias / gbif-alert

GBIF Alert is a GBIF occurrence based alert system.
https://gbif-alert-demo.thebinaryforest.net/
MIT License
8 stars 2 forks source link

git describe --always --tags issues #282

Open silenius opened 5 months ago

silenius commented 5 months ago

In dashboard/templates/dashboard/_footer.html the version is displayed. It uses:

def human_readable_git_version_number() -> str:
    """Return the git tag name (if available) or the git commit hash (if not)"""
    return subprocess.check_output(
        ["git", "describe", "--always", "--tags"], encoding="UTF-8"
    ).strip()

from dashboard/utils.py under the hood.

In our deployment only some directories are owned and/or writable by the user (for security reasons) and git describe fails:

www-py311-2024Q2% git describe --always --tags
fatal: detected dubious ownership in repository at '/usr/local/www/sites/gbif-alert'
To add an exception for this directory, call:

        git config --global --add safe.directory /usr/local/www/sites/gbif-alert

Another potential issue is that subprocess.check_output forks a new process which could be an issue if many clients are hitting the frontpage at the same time

niconoe commented 5 months ago

Thanks @silenius, indeed I wonder for a long time is this approach is sane (ideally, even having the git repository at the deployed location shouldn't be a requirement, I think). I'll look for another approach, the good thing about this one was that it worked everywhere and was easy, but something like running that command at release time and storing its output in a text file might be better!