summaryrefslogtreecommitdiff
path: root/searx/version.py
diff options
context:
space:
mode:
authorLéon Tiekötter <leon@tiekoetter.com>2022-02-21 13:28:47 +0100
committerLéon Tiekötter <leon@tiekoetter.com>2022-02-21 21:18:37 +0100
commitde5062c10a28073c435272b51a5d6317dd162f39 (patch)
tree14c30b8890033548c88c7302c78e2dff20611705 /searx/version.py
parent8230603f4834003c79938b472d1f6328b1af2ae8 (diff)
downloadsearxng-de5062c10a28073c435272b51a5d6317dd162f39.tar.gz
searxng-de5062c10a28073c435272b51a5d6317dd162f39.zip
[mod] version formatting
Change SearXNG version formatting to YYYY.MM.DD-commit_hash
Diffstat (limited to 'searx/version.py')
-rw-r--r--searx/version.py22
1 files changed, 2 insertions, 20 deletions
diff --git a/searx/version.py b/searx/version.py
index 9b3fcc35e..678dab4b2 100644
--- a/searx/version.py
+++ b/searx/version.py
@@ -2,7 +2,6 @@
# lint: pylint
# pylint: disable=,missing-module-docstring,missing-class-docstring
-import re
import os
import shlex
import subprocess
@@ -59,25 +58,8 @@ def get_git_url_and_branch():
def get_git_version():
- try:
- tag = subprocess_run("git describe HEAD")
- # a. HEAD is on tag name, example: tag = "v1.0.1"
- # b. HEAD is not a tag name, example "<tag>-<distance>-g<commit>"
- tag_version, tag_distance, tag_commit = (tag.split("-") + ["", ""])[:3]
- if re.match(r"v[0-9]+\.[0-9]+\.[0-9]+", tag_version):
- # tag_version "v1.0.0" becomes "1.0.0" (without the v)
- # other patterns are kept untouched
- tag_version = tag_version[1:]
- # remove "g" prefix from tag_commit
- if tag_commit and tag_commit[0] == "g":
- tag_commit = tag_commit[1:]
- # set git_version to "1.0.0-590-0686e274" or '1.0.0'
- git_version = "-".join(filter(bool, [tag_version, tag_distance, tag_commit]))
- except subprocess.CalledProcessError:
- # fall back to "YYYY.MM.DD.Hash" if there is no tag at all
- git_version = subprocess_run(r"git show -s --format='%as-%h'")
- # PEP 440: replace - with .
- tag_version = git_version = git_version.replace("-", ".")
+ git_commit_date_hash = subprocess_run(r"git show -s --format='%cs-%h'").replace("-", ".", 2)
+ tag_version = git_version = git_commit_date_hash
# add "-dirty" suffix if there are uncommited changes except searx/settings.yml
try: