From 1a24e7c5b683355335b115e5659eb6fe8c8d11dc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 26 Apr 2023 18:24:39 -0400 Subject: klippy: Report repo version as "dirty" if there are untracked python files Check for untracked files in the klippy/extras/ and klippy/kinematics/ directories and report those files in the log. This helps identify code modifications when inspecting a log. Signed-off-by: Kevin O'Connor --- klippy/util.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'klippy/util.py') diff --git a/klippy/util.py b/klippy/util.py index c21ace28..ffea918c 100644 --- a/klippy/util.py +++ b/klippy/util.py @@ -138,20 +138,30 @@ def get_git_version(from_file=True): # Obtain version info from "git" program gitdir = os.path.join(klippy_src, '..') - prog = ('git', '-C', gitdir, 'describe', '--always', - '--tags', '--long', '--dirty') + prog_desc = ('git', '-C', gitdir, 'describe', '--always', + '--tags', '--long', '--dirty') + prog_status = ('git', '-C', gitdir, 'status', '--porcelain', '--ignored') try: - process = subprocess.Popen(prog, stdout=subprocess.PIPE, + process = subprocess.Popen(prog_desc, stdout=subprocess.PIPE, stderr=subprocess.PIPE) ver, err = process.communicate() retcode = process.wait() if retcode == 0: - return str(ver.strip().decode()) + process = subprocess.Popen(prog_status, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stat, err = process.communicate() + status = [l.split(None, 1) + for l in str(stat.strip().decode()).split('\n')] + retcode = process.wait() + if retcode == 0: + return (str(ver.strip().decode()), status) + else: + logging.debug("Error getting git status: %s", err) else: logging.debug("Error getting git version: %s", err) except: logging.debug("Exception on run: %s", traceback.format_exc()) if from_file: - return get_version_from_file(klippy_src) - return "?" + return (get_version_from_file(klippy_src), []) + return ("?", []) -- cgit v1.2.3-70-g09d2