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

auto git auto created files

This commit is contained in:
Philip Sargent 2024-03-15 02:16:33 +00:00
parent d970942f04
commit dbfe72071e

View File

@ -103,11 +103,10 @@ 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():
@ -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,