From 6d0e70e8a44f7ff5e4310c9cebf24f6d3ce551d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Wed, 28 Feb 2024 10:29:13 +0100 Subject: [PATCH] replace gitpython with git call --- src/fact_base.py | 9 +++++---- src/install/requirements_common.txt | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fact_base.py b/src/fact_base.py index 63b5ae143..e1f23faf8 100644 --- a/src/fact_base.py +++ b/src/fact_base.py @@ -3,12 +3,13 @@ import signal import sys from pathlib import Path +from shlex import split +from subprocess import CalledProcessError, PIPE, run, STDOUT from time import sleep import config try: - import git import psutil import psycopg2 # noqa: F401 @@ -53,9 +54,9 @@ def __init__(self): @staticmethod def _get_git_revision() -> str: try: - repo = git.Repo(Path(__file__), search_parent_directories=True) - return f'commit {repo.head.object.hexsha}' - except git.exc.InvalidGitRepositoryError: + proc = run(split('git rev-parse --short HEAD'), stdout=PIPE, stderr=STDOUT, cwd=Path(__file__).parent) + return proc.stdout.decode().strip() + except CalledProcessError: return 'unknown revision' def _register_signal_handlers(self): diff --git a/src/install/requirements_common.txt b/src/install/requirements_common.txt index c5d4b3293..703894d82 100644 --- a/src/install/requirements_common.txt +++ b/src/install/requirements_common.txt @@ -7,7 +7,6 @@ setuptools<66 # General python dependencies appdirs==1.4.4 flaky==3.7.0 -gitpython~=3.1.40 lief==0.12.3 psutil==5.9.4 psycopg2-binary==2.9.5