summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/utils.py b/core/utils.py
index 38ae026..36f0982 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -2,6 +2,7 @@ import logging
import random
import resource
import subprocess
+import os
from decimal import getcontext
from pathlib import Path
@@ -108,7 +109,7 @@ def write_and_commit(files, message):
filename = filepath.name
# GIT see also core/views/uploads.py dwgupload()
# GIT see also core/views/expo.py editexpopage()
-
+ os.makedirs(os.path.dirname(filepath), exist_ok = True)
if encoding:
mode = "w"
kwargs = {"encoding": encoding}
@@ -144,10 +145,11 @@ 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", filename], cwd=cwd, capture_output=True, text=True)
+ filenames = [filepath.name for filepath, content, encoding in files]
+ subprocess.run([git, "commit"] + filenames + ["-m", message], cwd=cwd, capture_output=True, text=True)
+ cp_status = subprocess.run([git, "status"] + filenames, 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":
+ if not cp_status.stdout or len(cp_status.stdout) < 2 or cp_status.stdout.split("\n")[-2] != "nothing to commit, working tree clean":
msgdata = (
"Ask a nerd to fix this.\n\n"
+ cp_status.stderr