2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 00:57:15 +00:00

Bug fixes to allow adding of a new cave. No longer ask users about filenames or urls.

This commit is contained in:
Martin Green
2023-07-05 17:43:57 +01:00
parent 067fcd9892
commit 410a285085
4 changed files with 32 additions and 17 deletions

View File

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