feat: path budget - a file's path stays at 160 characters or fewer; new, rename, move and raw accept refuse more, lint reports Long Paths (#163)
Files changed: - CHANGES.md - README.md - VERSION - instructions/page-lifecycle.md - kb/CONTRACT.md - tools/CONTRACT.md - tools/chemenu/commands/_util.py - tools/chemenu/commands/lint.py - tools/chemenu/commands/new_page.py - tools/chemenu/commands/page_ops.py - tools/chemenu/commands/raw_cmd.py - tools/chemenu/lint_core.py - tools/chemenu/tests/test_lint.py - tools/chemenu/tests/test_new_page.py - tools/chemenu/tests/test_page_ops.py - tools/chemenu/tests/test_raw_cmd.py - tools/chemenu/tests/test_titles.py - tools/chemenu/titles.py
This commit is contained in:
1 parent
03743ebbc0
commit
04aebdeccf
18 files changed
+394
-29
No files matched your search
@@ -72,7 +72,7 @@ from typing import Optional
|
||||
import typer
|
||||
|
||||
from chemenu import cli_contract, config
|
||||
from chemenu.commands._util import fail, rel_path, success
|
||||
from chemenu.commands._util import check_path_budget, fail, rel_path, success
|
||||
from chemenu.frontmatter_io import write_page
|
||||
from chemenu.kb_scan import load_kb_pages
|
||||
from chemenu.provenance import citing_pages, source_pages_by_raw_file, source_raw_files
|
||||
@@ -371,9 +371,12 @@ def _replace(
|
||||
cli_contract.Failure(
|
||||
label="raw accept",
|
||||
cause="A file does not exist, is not under `incoming/`, or is nested more than one "
|
||||
"level below it; two files in one call share a filename; or a target path already "
|
||||
"exists",
|
||||
reaction="Fix the named argument and retry once",
|
||||
"level below it; two files in one call share a filename; a target path already "
|
||||
"exists; or a target path would be over the path budget (160 UTF-16 code units "
|
||||
"below the instance root)",
|
||||
reaction="Fix the named argument and retry once. For a path over the budget, "
|
||||
"rename the file in `incoming/` to something shorter - the refusal comes before "
|
||||
"anything moves, so `incoming/` and `raw/` are unchanged",
|
||||
),
|
||||
cli_contract.Failure(
|
||||
label="raw accept",
|
||||
@@ -562,6 +565,11 @@ def raw_accept_command(
|
||||
moves.append((new_path, dst))
|
||||
|
||||
for _src, dst in moves:
|
||||
check_path_budget(
|
||||
dst,
|
||||
"The name comes from the file in incoming/: rename it there to something shorter "
|
||||
"and accept it again.",
|
||||
)
|
||||
if dst.exists():
|
||||
fail(f"Cannot promote: {rel_path(dst)} already exists.")
|
||||
|
||||
|
||||
Reference in new issue
Block a user