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"{ff}

{ff}

{t}" p = Path(year_dir, ff+".html") if not p.is_file(): - p.write_text(f"{ff}

{ff}

{t}") - - - + 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 \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,