move git head functionality to function in util.py

This commit is contained in:
Mike Fährmann
2022-11-04 17:35:47 +01:00
parent 4fd3c893fa
commit 597b63d922
2 changed files with 20 additions and 13 deletions

View File

@@ -118,25 +118,15 @@ def main():
config.set(("output",), "mode", "null")
elif args.loglevel <= logging.DEBUG:
import platform
import subprocess
import os.path
import requests
extra = ""
if getattr(sys, "frozen", False):
extra = " - Executable"
else:
try:
out, err = subprocess.Popen(
("git", "rev-parse", "--short", "HEAD"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=os.path.dirname(os.path.abspath(__file__)),
).communicate()
if out and not err:
extra = " - Git HEAD: " + out.decode().rstrip()
except (OSError, subprocess.SubprocessError):
pass
git_head = util.git_head()
if git_head:
extra = " - Git HEAD: " + git_head
log.debug("Version %s%s", __version__, extra)
log.debug("Python %s - %s",