summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-03-15 02:16:33 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2024-03-15 02:16:33 +0000
commitdbfe72071e3699cf3f210ecb34ec7933eb123857 (patch)
tree17fdcfc1dac4c5fe6d950186920b9a1299b38853 /core/utils.py
parentd970942f04ade166f2704eb33d70268d39855831 (diff)
downloadtroggle-dbfe72071e3699cf3f210ecb34ec7933eb123857.tar.gz
troggle-dbfe72071e3699cf3f210ecb34ec7933eb123857.tar.bz2
troggle-dbfe72071e3699cf3f210ecb34ec7933eb123857.zip
auto git auto created files
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/utils.py b/core/utils.py
index 052e9b8..e5d2726 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -103,12 +103,11 @@ def make_new_expo_dir(year):
if not year_dir.is_dir():
year_dir.mkdir(parents=True, exist_ok=True)
for ff in ["index","logbook", "mission"]:
+ content = f"<html><head><title>{ff}</title></head><body><h1>{ff}</h1>{t}</body></html>"
p = Path(year_dir, ff+".html")
if not p.is_file():
- p.write_text(f"<html><head><title>{ff}</title></head><body><h1>{ff}</h1>{t}</body></html>")
-
-
-
+ writetrogglefile(p, content, commit_msg="Auto new year file creation")
+
def current_expo():
expos = Expedition.objects.all().order_by('-year')
@@ -281,7 +280,7 @@ class WriteAndCommitError(Exception):
return f"WriteAndCommitError: {self.message}"
-def writetrogglefile(filepath, filecontent):
+def writetrogglefile(filepath, filecontent, commit_msg=None):
"""
REPLACE with call to write_and_commit + any necessary setup
@@ -308,8 +307,10 @@ def writetrogglefile(filepath, filecontent):
out = out[:75] + "\n <Long output curtailed>\n" + out[-75:]
print(f"git ADD {cwd}:\n\n" + str(sp.stderr) + "\n\n" + out + "\n\nreturn code: " + str(sp.returncode))
+ if not commit_msg:
+ commit_msg = f"Troggle online: cave or entrance edit -{filename}"
sp = subprocess.run(
- [git, "commit", "-m", f"Troggle online: cave or entrance edit -{filename}"],
+ [git, "commit", "-m", commit_msg],
cwd=cwd,
capture_output=True,
check=True,