drydock-cli 3.0.50__tar.gz → 3.0.51__tar.gz
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.
- {drydock_cli-3.0.50/drydock_cli.egg-info → drydock_cli-3.0.51}/PKG-INFO +1 -1
- drydock_cli-3.0.51/drydock/gittools.py +96 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tools/__init__.py +107 -1
- {drydock_cli-3.0.50 → drydock_cli-3.0.51/drydock_cli.egg-info}/PKG-INFO +1 -1
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock_cli.egg-info/SOURCES.txt +2 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/pyproject.toml +1 -1
- drydock_cli-3.0.51/tests/test_gittools.py +78 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/LICENSE +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/NOTICE +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/README.md +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/__init__.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/__main__.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/agent.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/bash_safety.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/cli.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/compaction.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/config.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/detect.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/graphrag.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/guards.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/loop_detect.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/providers.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tool_registry.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tui/__init__.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tui/app.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tui/approval.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tui/messages.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tui/widgets.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/tuning.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock/web.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock_cli.egg-info/dependency_links.txt +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock_cli.egg-info/entry_points.txt +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock_cli.egg-info/requires.txt +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/drydock_cli.egg-info/top_level.txt +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/setup.cfg +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_approval.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_back_command.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_bash_process_group.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_bash_safety.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_bash_timeout_network.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_cli_agents.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_compact_command.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_compaction.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_config.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_config_migration.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_context_limit_config.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_detect.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_empty_response.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_failure_loop.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_first_run_setup.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_graphrag.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_guards_and_tools.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_hallucinated_tools.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_leaked_tool_call.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_loop_detect.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_oneshot_unreachable.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_plan_autocontinue.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_providers_unreachable.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_runaway_repetition.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_stop.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_streaming_newlines.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_subagent.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_todo.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_tool_arg_parsing.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_tools_undo.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_tui.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_tuning.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_vision_input.py +0 -0
- {drydock_cli-3.0.50 → drydock_cli-3.0.51}/tests/test_web_tools.py +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Dedicated Version Control helpers — first-class git for the agent.
|
|
2
|
+
|
|
3
|
+
Git works through the generic Bash tool, but purpose-built git_* tools give the
|
|
4
|
+
model concise, structured, TRUNCATED output (a raw `git diff` can blow the
|
|
5
|
+
context window) and a safe commit path, without it having to remember exact git
|
|
6
|
+
invocations. Read ops (status/diff/log) are side-effect-free; commit is local
|
|
7
|
+
and reversible (push stays gated through Bash's approval modal).
|
|
8
|
+
|
|
9
|
+
All logic original to Drydock.
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import subprocess
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GitError(RuntimeError):
|
|
17
|
+
"""A git operation failed (not a repo, git missing, or a command error)."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _run_git(args: list[str], cwd: str, timeout: float = 30.0) -> str:
|
|
21
|
+
"""Run `git <args>` in cwd, returning stdout. Raises GitError on failure."""
|
|
22
|
+
try:
|
|
23
|
+
p = subprocess.run(
|
|
24
|
+
["git", *args], cwd=cwd, capture_output=True, text=True,
|
|
25
|
+
timeout=timeout,
|
|
26
|
+
)
|
|
27
|
+
except FileNotFoundError as e:
|
|
28
|
+
raise GitError("git is not installed or not on PATH") from e
|
|
29
|
+
except subprocess.TimeoutExpired as e:
|
|
30
|
+
raise GitError(f"git {args[0]} timed out after {timeout:.0f}s") from e
|
|
31
|
+
if p.returncode != 0:
|
|
32
|
+
err = (p.stderr or p.stdout or "").strip()
|
|
33
|
+
if "not a git repository" in err.lower():
|
|
34
|
+
raise GitError(f"not a git repository: {cwd}")
|
|
35
|
+
raise GitError(err or f"git {args[0]} failed (exit {p.returncode})")
|
|
36
|
+
return p.stdout
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _truncate(text: str, max_chars: int, *, tail: bool = False) -> str:
|
|
40
|
+
if len(text) <= max_chars:
|
|
41
|
+
return text
|
|
42
|
+
note = f"\n[... {len(text) - max_chars} chars truncated ...]\n"
|
|
43
|
+
return (note + text[-max_chars:]) if tail else (text[:max_chars] + note)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def status(cwd: str) -> str:
|
|
47
|
+
"""Branch + concise porcelain status of the working tree."""
|
|
48
|
+
branch = _run_git(["rev-parse", "--abbrev-ref", "HEAD"], cwd).strip()
|
|
49
|
+
porcelain = _run_git(["status", "--porcelain=v1", "--branch"], cwd).strip()
|
|
50
|
+
if len(porcelain.splitlines()) <= 1: # only the "## branch" header line
|
|
51
|
+
return f"On branch {branch}. Working tree clean."
|
|
52
|
+
return f"On branch {branch}:\n{_truncate(porcelain, 4000)}"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def diff(cwd: str, path: str | None = None, *, staged: bool = False,
|
|
56
|
+
max_chars: int = 8000) -> str:
|
|
57
|
+
"""Working-tree (or --staged) diff, optionally scoped to a path. Truncated."""
|
|
58
|
+
args = ["diff"]
|
|
59
|
+
if staged:
|
|
60
|
+
args.append("--cached")
|
|
61
|
+
if path:
|
|
62
|
+
args += ["--", path]
|
|
63
|
+
out = _run_git(args, cwd)
|
|
64
|
+
if not out.strip():
|
|
65
|
+
scope = " (staged)" if staged else ""
|
|
66
|
+
return f"No{scope} changes" + (f" in {path}" if path else "") + "."
|
|
67
|
+
# Lead with a --stat summary so the model sees the shape even when truncated.
|
|
68
|
+
stat_args = ["diff", "--stat"] + (["--cached"] if staged else [])
|
|
69
|
+
if path:
|
|
70
|
+
stat_args += ["--", path]
|
|
71
|
+
stat = _run_git(stat_args, cwd).strip()
|
|
72
|
+
return f"{stat}\n\n{_truncate(out, max_chars)}"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def log(cwd: str, n: int = 10) -> str:
|
|
76
|
+
"""The last n commits, one line each."""
|
|
77
|
+
n = max(1, min(n, 50))
|
|
78
|
+
out = _run_git(["log", f"-{n}", "--oneline", "--decorate"], cwd).strip()
|
|
79
|
+
return out or "No commits yet."
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def commit(cwd: str, message: str, *, add_all: bool = True) -> str:
|
|
83
|
+
"""Stage (all, by default) and commit. Local + reversible (git reset undoes
|
|
84
|
+
it). Refuses an empty message. Does NOT push."""
|
|
85
|
+
message = (message or "").strip()
|
|
86
|
+
if not message:
|
|
87
|
+
raise GitError("a commit needs a non-empty message")
|
|
88
|
+
if add_all:
|
|
89
|
+
_run_git(["add", "-A"], cwd)
|
|
90
|
+
# Nothing staged → say so instead of erroring opaquely.
|
|
91
|
+
staged = _run_git(["diff", "--cached", "--name-only"], cwd).strip()
|
|
92
|
+
if not staged:
|
|
93
|
+
return "Nothing to commit — the working tree has no staged changes."
|
|
94
|
+
out = _run_git(["commit", "-m", message], cwd)
|
|
95
|
+
head = _run_git(["rev-parse", "--short", "HEAD"], cwd).strip()
|
|
96
|
+
return f"Committed {head}:\n{out.strip()}"
|
|
@@ -161,6 +161,56 @@ SCHEMAS = [
|
|
|
161
161
|
"required": ["prompt"],
|
|
162
162
|
},
|
|
163
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"name": "GitStatus",
|
|
166
|
+
"description": (
|
|
167
|
+
"Show the current branch and a concise list of changed/staged/"
|
|
168
|
+
"untracked files (git status). Use it to understand the working tree "
|
|
169
|
+
"before editing or committing."
|
|
170
|
+
),
|
|
171
|
+
"input_schema": {"type": "object", "properties": {}},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "GitDiff",
|
|
175
|
+
"description": (
|
|
176
|
+
"Show the diff of changes (git diff), with a --stat summary first and "
|
|
177
|
+
"the body truncated to fit context. Set staged=true for staged "
|
|
178
|
+
"changes; pass a path to scope it to one file/dir."
|
|
179
|
+
),
|
|
180
|
+
"input_schema": {
|
|
181
|
+
"type": "object",
|
|
182
|
+
"properties": {
|
|
183
|
+
"path": {"type": "string", "description": "Optional file/dir to scope the diff."},
|
|
184
|
+
"staged": {"type": "boolean", "description": "Diff staged changes instead of the working tree."},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "GitLog",
|
|
190
|
+
"description": "Show the last n commits, one line each (git log --oneline).",
|
|
191
|
+
"input_schema": {
|
|
192
|
+
"type": "object",
|
|
193
|
+
"properties": {
|
|
194
|
+
"n": {"type": "integer", "description": "How many commits (default 10)."},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "GitCommit",
|
|
200
|
+
"description": (
|
|
201
|
+
"Stage all changes and commit with a message (git add -A && git "
|
|
202
|
+
"commit). Local and reversible; does NOT push. Use it to package a "
|
|
203
|
+
"completed, verified change. Write a clear, specific message."
|
|
204
|
+
),
|
|
205
|
+
"input_schema": {
|
|
206
|
+
"type": "object",
|
|
207
|
+
"properties": {
|
|
208
|
+
"message": {"type": "string", "description": "The commit message."},
|
|
209
|
+
"add_all": {"type": "boolean", "description": "Stage all changes first (default true)."},
|
|
210
|
+
},
|
|
211
|
+
"required": ["message"],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
164
214
|
{
|
|
165
215
|
"name": "WebSearch",
|
|
166
216
|
"description": (
|
|
@@ -769,6 +819,54 @@ def tool_task(params: dict, config: dict) -> str:
|
|
|
769
819
|
return f"[sub-agent finished {steps} step(s) with no summary]"
|
|
770
820
|
|
|
771
821
|
|
|
822
|
+
def _git_cwd(config: dict) -> str:
|
|
823
|
+
return config.get("cwd") or os.getcwd()
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def tool_gitstatus(params: dict, config: dict) -> str:
|
|
827
|
+
from drydock import gittools
|
|
828
|
+
try:
|
|
829
|
+
return gittools.status(_git_cwd(config))
|
|
830
|
+
except gittools.GitError as e:
|
|
831
|
+
return f"git status failed: {e}"
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
def tool_gitdiff(params: dict, config: dict) -> str:
|
|
835
|
+
from drydock import gittools
|
|
836
|
+
try:
|
|
837
|
+
return gittools.diff(
|
|
838
|
+
_git_cwd(config),
|
|
839
|
+
path=(params.get("path") or None),
|
|
840
|
+
staged=bool(params.get("staged")),
|
|
841
|
+
)
|
|
842
|
+
except gittools.GitError as e:
|
|
843
|
+
return f"git diff failed: {e}"
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
def tool_gitlog(params: dict, config: dict) -> str:
|
|
847
|
+
from drydock import gittools
|
|
848
|
+
try:
|
|
849
|
+
n = int(params.get("n") or 10)
|
|
850
|
+
except (TypeError, ValueError):
|
|
851
|
+
n = 10
|
|
852
|
+
try:
|
|
853
|
+
return gittools.log(_git_cwd(config), n=n)
|
|
854
|
+
except gittools.GitError as e:
|
|
855
|
+
return f"git log failed: {e}"
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
def tool_gitcommit(params: dict, config: dict) -> str:
|
|
859
|
+
from drydock import gittools
|
|
860
|
+
try:
|
|
861
|
+
return gittools.commit(
|
|
862
|
+
_git_cwd(config),
|
|
863
|
+
params.get("message") or "",
|
|
864
|
+
add_all=params.get("add_all", True) is not False,
|
|
865
|
+
)
|
|
866
|
+
except gittools.GitError as e:
|
|
867
|
+
return f"git commit failed: {e}"
|
|
868
|
+
|
|
869
|
+
|
|
772
870
|
def tool_websearch(params: dict, config: dict) -> str:
|
|
773
871
|
"""Search the internet (DuckDuckGo). Read-only; clean message when offline."""
|
|
774
872
|
from drydock import web
|
|
@@ -845,6 +943,10 @@ _TOOLS = [
|
|
|
845
943
|
("Knowledge", tool_knowledge, True),
|
|
846
944
|
("WebSearch", tool_websearch, True),
|
|
847
945
|
("WebFetch", tool_webfetch, True),
|
|
946
|
+
("GitStatus", tool_gitstatus, True),
|
|
947
|
+
("GitDiff", tool_gitdiff, True),
|
|
948
|
+
("GitLog", tool_gitlog, True),
|
|
949
|
+
("GitCommit", tool_gitcommit, False),
|
|
848
950
|
]
|
|
849
951
|
|
|
850
952
|
def register_all():
|
|
@@ -855,10 +957,14 @@ def register_all():
|
|
|
855
957
|
"Bash": tool_bash, "Glob": tool_glob, "Grep": tool_grep,
|
|
856
958
|
"todo": tool_todo, "task": tool_task, "Knowledge": tool_knowledge,
|
|
857
959
|
"WebSearch": tool_websearch, "WebFetch": tool_webfetch,
|
|
960
|
+
"GitStatus": tool_gitstatus, "GitDiff": tool_gitdiff,
|
|
961
|
+
"GitLog": tool_gitlog, "GitCommit": tool_gitcommit,
|
|
858
962
|
}[name]
|
|
859
|
-
#
|
|
963
|
+
# Read-only w.r.t. the parent's files (GitStatus/Diff/Log inspect only;
|
|
964
|
+
# GitCommit writes a local, reversible commit).
|
|
860
965
|
read_only = name in (
|
|
861
966
|
"Read", "Glob", "Grep", "task", "Knowledge", "WebSearch", "WebFetch",
|
|
967
|
+
"GitStatus", "GitDiff", "GitLog",
|
|
862
968
|
)
|
|
863
969
|
register(ToolDef(name=name, schema=schema, func=func, read_only=read_only))
|
|
864
970
|
|
|
@@ -10,6 +10,7 @@ drydock/cli.py
|
|
|
10
10
|
drydock/compaction.py
|
|
11
11
|
drydock/config.py
|
|
12
12
|
drydock/detect.py
|
|
13
|
+
drydock/gittools.py
|
|
13
14
|
drydock/graphrag.py
|
|
14
15
|
drydock/guards.py
|
|
15
16
|
drydock/loop_detect.py
|
|
@@ -44,6 +45,7 @@ tests/test_detect.py
|
|
|
44
45
|
tests/test_empty_response.py
|
|
45
46
|
tests/test_failure_loop.py
|
|
46
47
|
tests/test_first_run_setup.py
|
|
48
|
+
tests/test_gittools.py
|
|
47
49
|
tests/test_graphrag.py
|
|
48
50
|
tests/test_guards_and_tools.py
|
|
49
51
|
tests/test_hallucinated_tools.py
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
# PyPI distribution name is drydock-cli (the established install name, continued
|
|
8
8
|
# from the retired v2 fork); the import package + CLI command stay `drydock`.
|
|
9
9
|
name = "drydock-cli"
|
|
10
|
-
version = "3.0.
|
|
10
|
+
version = "3.0.51"
|
|
11
11
|
description = "Drydock — a local, provider-agnostic terminal coding agent for local LLMs"
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.11"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Dedicated Version Control tools (drydock/gittools.py): structured, truncated
|
|
2
|
+
git for the agent. Tests run in isolated temp repos."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from drydock import gittools
|
|
10
|
+
from drydock.tools import (
|
|
11
|
+
tool_gitstatus, tool_gitdiff, tool_gitlog, tool_gitcommit,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _git(args, cwd):
|
|
16
|
+
subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, text=True)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def repo(tmp_path):
|
|
21
|
+
_git(["init", "-q"], tmp_path)
|
|
22
|
+
_git(["config", "user.email", "t@t.com"], tmp_path)
|
|
23
|
+
_git(["config", "user.name", "T"], tmp_path)
|
|
24
|
+
(tmp_path / "a.txt").write_text("hello\n")
|
|
25
|
+
_git(["add", "-A"], tmp_path)
|
|
26
|
+
_git(["commit", "-qm", "initial"], tmp_path)
|
|
27
|
+
return tmp_path
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_status_clean_then_dirty(repo):
|
|
31
|
+
cfg = {"cwd": str(repo)}
|
|
32
|
+
assert "clean" in tool_gitstatus({}, cfg).lower()
|
|
33
|
+
(repo / "a.txt").write_text("hello\nworld\n")
|
|
34
|
+
out = tool_gitstatus({}, cfg)
|
|
35
|
+
assert "a.txt" in out and "clean" not in out.lower()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_diff_shows_stat_and_body(repo):
|
|
39
|
+
(repo / "a.txt").write_text("hello\nchanged\n")
|
|
40
|
+
out = tool_gitdiff({}, {"cwd": str(repo)})
|
|
41
|
+
assert "a.txt" in out and "changed" in out and "insertion" in out
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_diff_no_changes(repo):
|
|
45
|
+
assert "No changes" in tool_gitdiff({}, {"cwd": str(repo)})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_log_lists_commits(repo):
|
|
49
|
+
out = tool_gitlog({"n": 5}, {"cwd": str(repo)})
|
|
50
|
+
assert "initial" in out
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_commit_stages_and_commits(repo):
|
|
54
|
+
(repo / "b.txt").write_text("new file\n")
|
|
55
|
+
out = tool_gitcommit({"message": "add b"}, {"cwd": str(repo)})
|
|
56
|
+
assert "Committed" in out
|
|
57
|
+
assert "add b" in tool_gitlog({}, {"cwd": str(repo)})
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_commit_empty_message_refused(repo):
|
|
61
|
+
(repo / "b.txt").write_text("x")
|
|
62
|
+
assert "non-empty message" in tool_gitcommit({"message": " "}, {"cwd": str(repo)})
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_commit_nothing_to_commit(repo):
|
|
66
|
+
assert "Nothing to commit" in tool_gitcommit({"message": "noop"}, {"cwd": str(repo)})
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_not_a_repo_is_graceful(tmp_path):
|
|
70
|
+
out = tool_gitstatus({}, {"cwd": str(tmp_path)})
|
|
71
|
+
assert "not a git repository" in out.lower()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_diff_truncates_large_body(repo):
|
|
75
|
+
# modify a TRACKED file so it appears in the working-tree diff
|
|
76
|
+
(repo / "a.txt").write_text("\n".join(f"line {i}" for i in range(5000)))
|
|
77
|
+
out = gittools.diff(str(repo), max_chars=1000)
|
|
78
|
+
assert "truncated" in out and len(out) < 4000
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|