mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-03-30 08:29:51 +01:00
oops
This commit is contained in:
@@ -233,19 +233,19 @@ nothing to commit, working tree clean
|
||||
f"CANNOT git COMMIT on server for this file {filename}. Subprocess error. Edits not saved.\nAsk a nerd to fix this."
|
||||
)
|
||||
|
||||
def g_string(author_string):
|
||||
def git_string(author_string):
|
||||
|
||||
# Regular expression for a git-compatible author string
|
||||
# valid example "John Doe <john.doe@example.com>"
|
||||
|
||||
author_regex = re.compile(r'^[a-zA-Z][\w\s\.\-]* <[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}>$')
|
||||
author_regex = re.compile(r'^[a-zA-Z][\w\s\_\.\-]* <[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,}>$')
|
||||
|
||||
if author_regex.match(author_string):
|
||||
print(f"Valid git-compatible author string: {author_string}")
|
||||
print(f"Valid git-compatible author string: '{author_string}'")
|
||||
return author_string
|
||||
else:
|
||||
editor = author_string.replace("@","_at_")
|
||||
editor = re.sub('[^0-9a-zA-Z_]+', '*', editor)
|
||||
editor = re.sub('[^0-9a-zA-Z_\.]+', '*', editor)
|
||||
editor += f" <{editor}@potatohut.expo>"
|
||||
print(f"Not git-compatible author string, replacing as '{editor}'")
|
||||
return editor
|
||||
@@ -258,7 +258,7 @@ def write_and_commit(files, message, editor=None):
|
||||
git = settings.GIT
|
||||
commands = []
|
||||
if editor:
|
||||
editor = g_string(editor)
|
||||
editor = git_string(editor)
|
||||
else:
|
||||
# cannot happen as form verification has this as an obligatory field
|
||||
editor = "Automatic <automaton@potatohut.expo>"
|
||||
@@ -373,6 +373,10 @@ class WriteAndCommitError(Exception):
|
||||
def writetrogglefile(filepath, filecontent, commit_msg=None):
|
||||
"""
|
||||
REPLACE with call to write_and_commit + any necessary setup
|
||||
used only by cave editor in
|
||||
core/models/caves.py
|
||||
and by
|
||||
make_new_expo_dir(year)
|
||||
|
||||
Commit the new saved file to git
|
||||
Callers to cave.writeDataFile() or entrance.writeDataFile() should handle the exception PermissionsError explicitly
|
||||
|
||||
Reference in New Issue
Block a user