2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00

beter(?) git error reporting

This commit is contained in:
Philip Sargent 2023-11-10 15:33:04 +02:00
parent 08c56644eb
commit 0c1601e1b0

View File

@ -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: