summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-11-10 15:33:04 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2023-11-10 15:33:04 +0200
commit0c1601e1b069f216cec3372ceee8b154f842c285 (patch)
tree5ed5148377bfec956df7f5a9e524e39065f13d8d /core/utils.py
parent08c56644ebfd694c3f57de1e9b9e7afcfef1dba2 (diff)
downloadtroggle-0c1601e1b069f216cec3372ceee8b154f842c285.tar.gz
troggle-0c1601e1b069f216cec3372ceee8b154f842c285.tar.bz2
troggle-0c1601e1b069f216cec3372ceee8b154f842c285.zip
beter(?) git error reporting
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/utils.py b/core/utils.py
index a76f41f..88a4b1b 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -180,7 +180,9 @@ def write_and_commit(files, message):
cmd_add = [git, "add", filename]
cp_add = subprocess.run(cmd_add, cwd=cwd, capture_output=True, text=True)
commands.append(cmd_add)
+ git_add_returncode = ""
if cp_add.returncode != 0:
+ git_add_returncode = cp_add.returncode
msgdata = (
"Ask a nerd to fix this.\n\n"
+ cp_add.stderr
@@ -190,7 +192,7 @@ def write_and_commit(files, message):
+ str(cp_add.returncode)
)
raise WriteAndCommitError(
- f"CANNOT git on server for this file {filename}. Edits saved but not added to git.\n\n"
+ f"PROBLEM with git on server for {filename}. Edits saved but [possibly] not added to git.\n\n"
+ msgdata
)
else:
@@ -199,7 +201,7 @@ def write_and_commit(files, message):
cmd_commit = [git, "commit"] + filepaths + ["-m", message]
cm_status = subprocess.run(cmd_commit, cwd=cwd, capture_output=True, text=True)
commands.append(cmd_commit)
- if cm_status == 0:
+ if cm_status.returncode != 0:
msgdata = (
"Commands: " + str(commands) +
"Ask a nerd to fix this.\n\n"
@@ -207,9 +209,10 @@ def write_and_commit(files, message):
+ "\n\n"
+ "Stdout: " + cp_status.stdout
+ "\n\nreturn code: " + str(cp_status.returncode)
+ + "\n\ngit add return code in previous operation was: " + git_add_returncode
)
raise WriteAndCommitError(
- f"Error committing. Edits saved, added to git, but NOT committed.\n\n"
+ f"ERROR committing. Edits saved, [maybe] added to git, but NOT committed.\n\n"
+ msgdata
)
cmd_status = [git, "status"] + filepaths
@@ -226,7 +229,7 @@ def write_and_commit(files, message):
+ "\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"
+ f"Error code with git on server for this file {filename}. Edits saved, added to git, but NOT committed. Git status not clean.\n\n"
+ msgdata
)
except subprocess.SubprocessError: