diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-08-31 01:09:37 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-08-31 15:53:33 +0200 |
| commit | 284f3972844ea124c0cd9ee5500e99440bb96aac (patch) | |
| tree | b8dee22222c38b12cc00daf98280e1b2060bcca7 /g2h/file.py | |
| parent | b06dbf67b9ac9e329922d7911ee7a9b09419c5f0 (diff) | |
| download | git2hugo-284f3972844ea124c0cd9ee5500e99440bb96aac.tar.gz | |
g2h: Add file page
Also move helpers to dedicated files.
Diffstat (limited to 'g2h/file.py')
| -rw-r--r-- | g2h/file.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/g2h/file.py b/g2h/file.py new file mode 100644 index 0000000..8f683cd --- /dev/null +++ b/g2h/file.py @@ -0,0 +1,16 @@ +import os + +def sanitize_file_name(file_name, files): + if not file_name.startswith('.'): + return file_name + + file_names = [ f.name for f in files ] + for i in range(1, 10): + new_name = file_name.replace('.', '_' * i, 1) + if not new_name in file_names: + return new_name + + raise RuntimeError('Couldn not find unused sanitized file name') + +def tree_join(commit, path): + return os.path.join(commit.hexsha, 't', path) |