summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorMartin Green <martin.speleo@gmail.com>2023-05-01 22:06:48 +0100
committerMartin Green <martin.speleo@gmail.com>2023-05-01 22:06:48 +0100
commit783154d24a0033bbda15ebfa4e30744d02c27324 (patch)
tree8b6011dda3c73bcd56d055c6068b4ac5e3e2cde0 /core/utils.py
parent40126f6e2f6fb9a517c80d31cd34624fff50e4d1 (diff)
downloadtroggle-783154d24a0033bbda15ebfa4e30744d02c27324.tar.gz
troggle-783154d24a0033bbda15ebfa4e30744d02c27324.tar.bz2
troggle-783154d24a0033bbda15ebfa4e30744d02c27324.zip
Restored check of git status after a committ, but only for the one file being committed
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/core/utils.py b/core/utils.py
index 66e0bdc..38ae026 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -145,22 +145,21 @@ def write_and_commit(files, message):
else:
print(f"No change {filepath}")
subprocess.run([git, "commit", filename, "-m", message], cwd=cwd, capture_output=True, text=True)
- #cp_status = subprocess.run([git, "status"], cwd=cwd, capture_output=True, text=True)
- # This produces return code = 1 if it commits OK, but when the repo still needs to be pushed to origin/expoweb
- #if cp_status.stdout.split("\n")[-2] != "nothing to commit, working tree clean":
- # print("FOO: ", cp_status.stdout.split("\n")[-2])
- # msgdata = (
- # "Ask a nerd to fix this.\n\n"
- # + cp_status.stderr
- # + "\n\n"
- # + cp_status.stdout
- # + "\n\nreturn code: "
- # + str(cp_status.returncode)
- # )
- # raise WriteAndCommitError(
- # f"Error code with git on server for this file {filename}. Edits saved, added to git, but NOT committed.\n\n"
- # + msgdata
- # )
+ cp_status = subprocess.run([git, "status", filename], cwd=cwd, capture_output=True, text=True)
+ #This produces return code = 1 if it commits OK, but when the repo still needs to be pushed to origin/expoweb
+ if cp_status.stdout.split("\n")[-2] != "nothing to commit, working tree clean":
+ msgdata = (
+ "Ask a nerd to fix this.\n\n"
+ + cp_status.stderr
+ + "\n\n"
+ + cp_status.stdout
+ + "\n\nreturn code: "
+ + str(cp_status.returncode)
+ )
+ raise WriteAndCommitError(
+ f"Error code with git on server for this file {filename}. Edits saved, added to git, but NOT committed.\n\n"
+ + msgdata
+ )
except subprocess.SubprocessError:
raise WriteAndCommitError(
f"CANNOT git on server for this file {filename}. Subprocess error. Edits not saved.\nAsk a nerd to fix this."