diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2023-04-26 18:24:39 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2023-05-02 11:40:18 -0400 |
commit | 1a24e7c5b683355335b115e5659eb6fe8c8d11dc (patch) | |
tree | d0ea04389877845545fb0f2de2561f5782d00d74 /klippy/util.py | |
parent | 3b0729c94932f4df0298a7c992022f54a5454428 (diff) | |
download | kutter-1a24e7c5b683355335b115e5659eb6fe8c8d11dc.tar.gz kutter-1a24e7c5b683355335b115e5659eb6fe8c8d11dc.tar.xz kutter-1a24e7c5b683355335b115e5659eb6fe8c8d11dc.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/util.py')
-rw-r--r-- | klippy/util.py | 22 |
1 files changed, 16 insertions, 6 deletions
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 ("?", []) |