filekeeper-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- filekeeper/__init__.py +35 -0
- filekeeper/cli/__init__.py +5 -0
- filekeeper/cli/app.py +866 -0
- filekeeper/cli/exit_codes.py +84 -0
- filekeeper/cli/output.py +244 -0
- filekeeper/core/__init__.py +51 -0
- filekeeper/core/config.py +133 -0
- filekeeper/core/database.py +226 -0
- filekeeper/core/diffing.py +127 -0
- filekeeper/core/errors.py +278 -0
- filekeeper/core/history/__init__.py +20 -0
- filekeeper/core/history/blobs.py +92 -0
- filekeeper/core/history/journal.py +430 -0
- filekeeper/core/history/repository.py +152 -0
- filekeeper/core/history/undo.py +358 -0
- filekeeper/core/models.py +293 -0
- filekeeper/core/operations/__init__.py +9 -0
- filekeeper/core/operations/directory.py +475 -0
- filekeeper/core/operations/edit.py +1239 -0
- filekeeper/core/operations/read.py +370 -0
- filekeeper/core/operations/search.py +198 -0
- filekeeper/core/operations/write.py +763 -0
- filekeeper/core/paths.py +236 -0
- filekeeper/core/safety/__init__.py +5 -0
- filekeeper/core/safety/atomic.py +129 -0
- filekeeper/core/safety/hashing.py +73 -0
- filekeeper/core/safety/sensitive.py +65 -0
- filekeeper/core/safety/textdata.py +142 -0
- filekeeper/core/safety/vcs.py +51 -0
- filekeeper/core/service.py +706 -0
- filekeeper/core/workspace.py +300 -0
- filekeeper_cli-0.1.0.dist-info/METADATA +498 -0
- filekeeper_cli-0.1.0.dist-info/RECORD +36 -0
- filekeeper_cli-0.1.0.dist-info/WHEEL +4 -0
- filekeeper_cli-0.1.0.dist-info/entry_points.txt +3 -0
- filekeeper_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Advisory "this path is version-control ignored" warning.
|
|
2
|
+
|
|
3
|
+
Warn-only: Filekeeper still performs the write, but the result carries a warning
|
|
4
|
+
so an agent can notice that a file it just wrote will not be committed. Git is
|
|
5
|
+
consulted through an argument list (never a shell) with a short timeout, and any
|
|
6
|
+
failure degrades to "unknown" rather than an error.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import subprocess
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
_TIMEOUT_SECONDS = 3.0
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _inside_git_worktree(root: Path, target: Path) -> bool:
|
|
18
|
+
for candidate in (root, *root.parents):
|
|
19
|
+
if (candidate / ".git").exists():
|
|
20
|
+
return True
|
|
21
|
+
return False
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def git_ignored(root: Path, target: Path) -> bool | None:
|
|
25
|
+
"""True/False when git can answer, ``None`` when it cannot or does not apply."""
|
|
26
|
+
|
|
27
|
+
if not _inside_git_worktree(root, target):
|
|
28
|
+
return None
|
|
29
|
+
try:
|
|
30
|
+
completed = subprocess.run(
|
|
31
|
+
["git", "-C", str(root), "check-ignore", "--quiet", "--", str(target)],
|
|
32
|
+
capture_output=True,
|
|
33
|
+
timeout=_TIMEOUT_SECONDS,
|
|
34
|
+
check=False,
|
|
35
|
+
)
|
|
36
|
+
except (OSError, subprocess.SubprocessError):
|
|
37
|
+
return None
|
|
38
|
+
if completed.returncode == 0:
|
|
39
|
+
return True
|
|
40
|
+
if completed.returncode == 1:
|
|
41
|
+
return False
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def ignore_warning(root: Path, target: Path, relative_path: str) -> str | None:
|
|
46
|
+
if git_ignored(root, target) is True:
|
|
47
|
+
return (
|
|
48
|
+
f"{relative_path} is ignored by version control; this change will not "
|
|
49
|
+
"appear in the repository"
|
|
50
|
+
)
|
|
51
|
+
return None
|