mirror of
https://github.com/open-webui/computer.git
synced 2026-12-01 17:32:54 -05:00
refac
This commit is contained in:
1 parent
5ad9072764
commit
ab6047d0fc
25 files changed
+1194
-198
No files matched your search
@@ -0,0 +1,28 @@
|
||||
"""Workspace filesystem helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def ensure_cptr_gitignored(workspace: str | Path) -> None:
|
||||
"""If workspace is a git repo, ensure .cptr is listed in .gitignore."""
|
||||
ws = Path(workspace)
|
||||
if not (ws / ".git").exists():
|
||||
return
|
||||
|
||||
gitignore = ws / ".gitignore"
|
||||
entry = ".cptr"
|
||||
|
||||
if gitignore.exists():
|
||||
content = gitignore.read_text(encoding="utf-8", errors="replace")
|
||||
for line in content.splitlines():
|
||||
stripped = line.strip()
|
||||
if stripped == entry or stripped == entry + "/":
|
||||
return
|
||||
if content and not content.endswith("\n"):
|
||||
content += "\n"
|
||||
content += f"{entry}\n"
|
||||
gitignore.write_text(content, encoding="utf-8")
|
||||
else:
|
||||
gitignore.write_text(f"{entry}\n", encoding="utf-8")
|
||||
Reference in new issue
Block a user