From dea5e289fecf9d42dfdf0b17a8c118863cdd448f Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Thu, 1 Jan 2026 02:34:14 +0400 Subject: [PATCH] refactor: simplify path normalization --- src/takopi/render.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/takopi/render.py b/src/takopi/render.py index 51b61f7..fb52a63 100644 --- a/src/takopi/render.py +++ b/src/takopi/render.py @@ -20,7 +20,6 @@ MAX_PROGRESS_CMD_LEN = 300 MAX_FILE_CHANGES_INLINE = 3 FILE_CHANGE_VERB = {"add": "added", "delete": "deleted", "update": "updated"} -_ABSOLUTE_PATH_PREFIXES = ("Users/", "home/", "private/", "var/", "etc/", "opt/", "usr/") def format_changed_file_path(path: str, *, base_dir: Path | None = None) -> str: @@ -28,10 +27,6 @@ def format_changed_file_path(path: str, *, base_dir: Path | None = None) -> str: if raw.startswith("./"): raw = raw[2:] - # Some clients may accidentally prefix "~" onto an absolute path (e.g. "~" + "/Users/…"). - if raw.startswith("~/") and raw[2:].startswith(_ABSOLUTE_PATH_PREFIXES): - raw = "/" + raw[2:] - base = Path.cwd() if base_dir is None else base_dir try: raw_path = Path(raw) @@ -109,7 +104,11 @@ def format_file_change_title(action: Action, *, command_width: int | None) -> st if not isinstance(path, str) or not path: continue kind = raw.get("kind") - verb = FILE_CHANGE_VERB.get(kind, "updated") if isinstance(kind, str) else "updated" + verb = ( + FILE_CHANGE_VERB.get(kind, "updated") + if isinstance(kind, str) + else "updated" + ) rendered.append(f"{verb} {format_changed_file_path(path)}") if rendered: