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: