witan-code 0.29.0__tar.gz → 0.30.0__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.
- {witan_code-0.29.0 → witan_code-0.30.0}/CHANGELOG.md +26 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/PKG-INFO +5 -4
- {witan_code-0.29.0 → witan_code-0.30.0}/README.md +3 -2
- {witan_code-0.29.0 → witan_code-0.30.0}/pyproject.toml +7 -3
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_cli_dispatch.py +74 -5
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_cli_hooks.py +21 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_cli_output_format.py +17 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_hooks.py +296 -17
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_remote_proxy.py +17 -5
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_remote_store.py +36 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/cli.py +48 -31
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/context.py +16 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/hooks.py +70 -34
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/indexer.py +50 -1
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/remote/store.py +25 -1
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/store.py +16 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/.gitignore +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/changelog.d/README.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/config/claude.json +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/config/copilot.json +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/config/pi.json +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/conftest.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/BRANCH_INDEXING.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/CLI_REFERENCE.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/EDGE_PRECISION_TIERS.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/PACKAGE_MAP.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/STAGE2_STITCHING.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/SYMBOL_FORMAT.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/SYMBOL_TABLE.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/docs/USER_GUIDE.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/install.sh +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/__init__.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/conftest.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_batched_deletes.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_branches.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_branches_served.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_bridge.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_chunked_load.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_cli_help_docstrings.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_cli_selected_target.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_config.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_config_targets.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_context.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_crossrepo.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_edges.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_elicit.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_enrichment.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_github_app.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_graph.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_identity.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_index_failure_diagnostics.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_index_reports_its_store.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_index_requires_a_repo_key.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_indexer.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_indexer_scope.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_ingest.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_languages.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_maintenance.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_package_map.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_reaper.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_rebuild_honours_the_repo_key.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_refusal_audit.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_repo.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_server.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_setup.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_stitch.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_store.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_symbol_table.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_tasks.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_tool_schema.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_views.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/tests/test_visualize.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/__init__.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/__main__.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/bridge.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/bridge_extractors.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/config.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/edges.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/elicit.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/extensions/pi/codegraph.ts +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/github_app.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/graph.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/identity.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/ingest.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/maintenance.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/output.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/package_map.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries/bridge.gq +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries/code_mutations.gq +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries/code_read.gq +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries/delete.gq +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/bash.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/hcl.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/python.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/sql.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/typescript.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/queries_ts/yaml.scm +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/reaper.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/remote/__init__.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/remote/oidc.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/remote/proxy.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/repo.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/schema/bridge-schema.pg +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/schema/code-schema.pg +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/selected_target.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/server.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/setup.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/skills/witan-code/SKILL.md +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/stitch.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/views.py +0 -0
- {witan_code-0.29.0 → witan_code-0.30.0}/witan_code/visualize.py +0 -0
|
@@ -8,6 +8,32 @@ a MINOR bump may include breaking changes).
|
|
|
8
8
|
|
|
9
9
|
<!-- scriv-insert-here -->
|
|
10
10
|
|
|
11
|
+
## [0.30.0] - 2026-11-12
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- The remote store client names itself `witan-code <version>` in its MCP `clientInfo` instead of the SDK default `mcp 0.1.0`, so the deployment's tool-call logs record which witan-code release made each call.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The pending queue is guarded by its own `codegraph-<digest>.pending.lock` file instead of a lock on the queue file, because Windows locks are mandatory and would block the holder's own reads through another handle. A drainer from the previous version still running during an upgrade does not exclude the new lock, so one queued edit can be dropped, once; the next edit to that file reindexes it.
|
|
20
|
+
- Requires witan-core 0.52.0 or later, the first release with `witan_core._filelock`.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- `witan-code symbols` with no detectable repo now prints its refusal to stderr and exits 1. It printed to stdout and exited 0, so a consumer parsing `--output-format json|toml|yaml` got a sentence instead of a document and could not tell the refusal from success.
|
|
25
|
+
- `witan-code branches --prune` against a remote deployment, a misconfigured remote (e.g. `WITAN_REMOTE_URL` without `WITAN_OIDC_ISSUER`), and a remote failure on any command (deployment unreachable, credential rejected, tool refused) print to stderr instead of stdout. All of them already exited 1. The umbrella `witan code ...` path prints remote failures through `witan`'s own handler instead, which goes to stderr from witan-council 0.48.0 and to stdout before it.
|
|
26
|
+
|
|
27
|
+
- The code-graph hooks (`session-init`, `reindex-hook` and the drainer they spawn) run on Windows. `witan_code.hooks` imported `fcntl` and `context.state_dir` called `os.getuid`, so every hook command failed there. The queue and checkout locks now go through `witan_core._filelock` (`flock` on POSIX, unchanged; `msvcrt.locking` on Windows). Windows cannot hand a lock to a child process, so there the hook checks the lock is free and the drainer takes it itself. The state directory on Windows is `%LOCALAPPDATA%\witan-code\state`, which only its owner can write to, rather than the temp dir, which `TEMP` can point at a shared directory.
|
|
28
|
+
|
|
29
|
+
- Error messages keep a long path on one line (e.g. the `reindex
|
|
30
|
+
--rebuild` refusal naming a subdirectory).
|
|
31
|
+
Rich hard-wrapped them at 80 columns when no standard stream is a
|
|
32
|
+
terminal (an agent's shell, a CI job), which put a newline inside any
|
|
33
|
+
longer path. Tables still wrap to the width.
|
|
34
|
+
|
|
35
|
+
- The edit and SessionStart hooks skip a repo the cluster does not serve instead of indexing it. Each attempt was refused with `ClusterGraphMissing`, which the hook discarded, but the server logged it and counted it as a failed tool call against its error-ratio alert. The drainer asks the cluster for its served graphs once per process (`code_store_graphs` through the MCP tier, `GET /graphs` direct) and indexes as before when that listing fails or comes back empty. An explicit `witan-code index` still reports the refusal.
|
|
36
|
+
|
|
11
37
|
## [0.29.0] - 2026-11-10
|
|
12
38
|
|
|
13
39
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: witan-code
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.0
|
|
4
4
|
Summary: witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)
|
|
5
5
|
Project-URL: Homepage, https://github.com/mitodl/agent-kit/tree/main/mcp/servers/witan-code
|
|
6
6
|
Project-URL: Repository, https://github.com/mitodl/agent-kit
|
|
@@ -26,7 +26,7 @@ Requires-Dist: tree-sitter-sql<0.4,>=0.3
|
|
|
26
26
|
Requires-Dist: tree-sitter-typescript<0.24,>=0.23
|
|
27
27
|
Requires-Dist: tree-sitter-yaml<0.8,>=0.7
|
|
28
28
|
Requires-Dist: tree-sitter<0.26,>=0.25
|
|
29
|
-
Requires-Dist: witan-core[cli,observability,remote,sentry]<1,>=0.
|
|
29
|
+
Requires-Dist: witan-core[cli,observability,remote,sentry]<1,>=0.52.0
|
|
30
30
|
Provides-Extra: tasks
|
|
31
31
|
Requires-Dist: fastmcp-tasks<5,>=4; extra == 'tasks'
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
@@ -701,8 +701,9 @@ symlink or copy the directory into the equivalent path for your agent.
|
|
|
701
701
|
## Hooks
|
|
702
702
|
|
|
703
703
|
Four hooks — all bare CLI commands, no wrapper scripts, so they need no
|
|
704
|
-
bash or setsid
|
|
705
|
-
|
|
704
|
+
bash or setsid and run on Windows as well as Linux and macOS (there against
|
|
705
|
+
a remote deployment, since omnigraph publishes no Windows binary for a local
|
|
706
|
+
store). Named `witan-code <command>` below (standalone install via
|
|
706
707
|
`witan-code setup`); when `witan setup` folds this bundle in instead (see
|
|
707
708
|
[Install](#install)), they register as `witan code <command>` so only
|
|
708
709
|
`witan` needs to be on `PATH`. Register manually per
|
|
@@ -668,8 +668,9 @@ symlink or copy the directory into the equivalent path for your agent.
|
|
|
668
668
|
## Hooks
|
|
669
669
|
|
|
670
670
|
Four hooks — all bare CLI commands, no wrapper scripts, so they need no
|
|
671
|
-
bash or setsid
|
|
672
|
-
|
|
671
|
+
bash or setsid and run on Windows as well as Linux and macOS (there against
|
|
672
|
+
a remote deployment, since omnigraph publishes no Windows binary for a local
|
|
673
|
+
store). Named `witan-code <command>` below (standalone install via
|
|
673
674
|
`witan-code setup`); when `witan setup` folds this bundle in instead (see
|
|
674
675
|
[Install](#install)), they register as `witan code <command>` so only
|
|
675
676
|
`witan` needs to be on `PATH`. Register manually per
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "witan-code"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.30.0"
|
|
4
4
|
description = "witan-code — tree-sitter code graph + cross-repo bridge (mounts under `witan code`)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "BSD-3-Clause"
|
|
@@ -218,7 +218,11 @@ dependencies = [
|
|
|
218
218
|
# imports and runs, but batches nodes and edges apart, so every flush adds
|
|
219
219
|
# a commit to the user's code branch. `_hashes_need_deferring` calls the
|
|
220
220
|
# same `chunk_records`, so 0.51.0 stays correct, only slower on the graph.
|
|
221
|
-
|
|
221
|
+
#
|
|
222
|
+
# ★ >=0.52 IS AN IMPORT FLOOR: hooks.py imports `witan_core._filelock`
|
|
223
|
+
# (added in witan-core 0.52.0 by #601) at module scope, so 0.51.1 cannot
|
|
224
|
+
# import the hook commands at all.
|
|
225
|
+
"witan-core[cli,remote,observability,sentry]>=0.52.0,<1",
|
|
222
226
|
"fastmcp>=4,<5",
|
|
223
227
|
"cyclopts>=4,<6",
|
|
224
228
|
# [targets.<name>] override models (config.py) — also transitively pulled
|
|
@@ -301,7 +305,7 @@ testpaths = ["tests"]
|
|
|
301
305
|
packages = ["witan_code"]
|
|
302
306
|
|
|
303
307
|
[tool.bumpversion]
|
|
304
|
-
current_version = "0.
|
|
308
|
+
current_version = "0.30.0"
|
|
305
309
|
allow_dirty = true
|
|
306
310
|
|
|
307
311
|
[[tool.bumpversion.files]]
|
|
@@ -9,6 +9,7 @@ regression here fails loudly instead of quietly going local-only.
|
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
|
+
import os
|
|
12
13
|
from types import SimpleNamespace
|
|
13
14
|
|
|
14
15
|
import pytest
|
|
@@ -109,7 +110,12 @@ def test_symbols_never_sends_a_directory_name_to_a_deployment(
|
|
|
109
110
|
|
|
110
111
|
monkeypatch.setattr("witan_code.repo.detect", _detect)
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
if remote:
|
|
114
|
+
with pytest.raises(SystemExit) as exc:
|
|
115
|
+
cli_module.symbols()
|
|
116
|
+
assert exc.value.code == 1
|
|
117
|
+
else:
|
|
118
|
+
cli_module.symbols()
|
|
113
119
|
|
|
114
120
|
# Last, not only: the local path loads config, whose target match detects too.
|
|
115
121
|
assert seen[-1] is fallback
|
|
@@ -284,10 +290,13 @@ def test_branches_prune_is_refused_in_remote_mode(monkeypatch, capsys):
|
|
|
284
290
|
monkeypatch.setattr(cli_module, "_srv", lambda: _stub(code_indexed_branches=[]))
|
|
285
291
|
monkeypatch.setattr(cli_module, "_is_remote", lambda: True)
|
|
286
292
|
|
|
287
|
-
with pytest.raises(SystemExit):
|
|
293
|
+
with pytest.raises(SystemExit) as exc:
|
|
288
294
|
cli_module.branches(prune=True)
|
|
289
295
|
|
|
290
|
-
assert
|
|
296
|
+
assert exc.value.code == 1
|
|
297
|
+
captured = capsys.readouterr()
|
|
298
|
+
assert "does not share" in captured.err
|
|
299
|
+
assert captured.out == ""
|
|
291
300
|
|
|
292
301
|
|
|
293
302
|
def test_branches_prune_is_refused_against_a_shared_store(monkeypatch, capsys):
|
|
@@ -354,11 +363,71 @@ def test_rebuild_refuses_a_path_that_is_not_the_repo_root(
|
|
|
354
363
|
with pytest.raises(SystemExit):
|
|
355
364
|
cli_module._rebuild_stores(sub, yes=True, slug="https://github.com/test/cg")
|
|
356
365
|
|
|
357
|
-
|
|
366
|
+
# Rich hard-wraps at the console width, and the wrap point moves with the
|
|
367
|
+
# length of tmp_path (i.e. TMPDIR), so compare with whitespace collapsed.
|
|
368
|
+
out = " ".join(capsys.readouterr().out.split())
|
|
358
369
|
assert "not the repo root" in out
|
|
359
370
|
assert str(root) in out
|
|
360
371
|
|
|
361
372
|
|
|
373
|
+
def _no_terminal(monkeypatch):
|
|
374
|
+
"""Make Rich see no terminal on any standard stream, with COLUMNS unset.
|
|
375
|
+
|
|
376
|
+
Rich sizes a console from fds 0, 1 and 2 before falling back to 80, so
|
|
377
|
+
clearing COLUMNS alone still picks up a terminal under ``pytest -s``.
|
|
378
|
+
"""
|
|
379
|
+
from rich.console import Console
|
|
380
|
+
|
|
381
|
+
def _not_a_terminal(*_args):
|
|
382
|
+
raise OSError
|
|
383
|
+
|
|
384
|
+
monkeypatch.delenv("COLUMNS", raising=False)
|
|
385
|
+
monkeypatch.setattr(os, "get_terminal_size", _not_a_terminal)
|
|
386
|
+
assert Console().width == 80
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def test_rebuild_refusal_keeps_a_long_path_on_one_line_when_piped(
|
|
390
|
+
tmp_path, monkeypatch, capsys
|
|
391
|
+
):
|
|
392
|
+
"""With no standard stream a terminal and COLUMNS unset, Rich renders at
|
|
393
|
+
80 columns, which is how an agent's shell or a CI job sees this CLI. A
|
|
394
|
+
hard-wrapped path longer than that is folded with a newline inside it, so
|
|
395
|
+
the path copied out of the refusal is not the path on disk.
|
|
396
|
+
"""
|
|
397
|
+
from witan_code import repo as repo_module
|
|
398
|
+
|
|
399
|
+
_no_terminal(monkeypatch)
|
|
400
|
+
root = (
|
|
401
|
+
tmp_path
|
|
402
|
+
/ "a-directory-name-long-enough-to-push-the-whole-path-past-eighty-columns"
|
|
403
|
+
)
|
|
404
|
+
sub = root / "src"
|
|
405
|
+
sub.mkdir(parents=True)
|
|
406
|
+
assert len(str(sub)) > 80
|
|
407
|
+
monkeypatch.setattr(repo_module, "git_toplevel", lambda _p: root)
|
|
408
|
+
|
|
409
|
+
with pytest.raises(SystemExit):
|
|
410
|
+
cli_module._rebuild_stores(sub, yes=True, slug="https://github.com/test/cg")
|
|
411
|
+
|
|
412
|
+
lines = capsys.readouterr().out.splitlines()
|
|
413
|
+
assert any(f"{sub} is not the repo root" in line for line in lines), lines
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
@pytest.mark.parametrize("stderr", [False, True])
|
|
417
|
+
def test_print_error_keeps_a_long_path_on_one_line_on_either_stream(
|
|
418
|
+
tmp_path, monkeypatch, capsys, stderr
|
|
419
|
+
):
|
|
420
|
+
_no_terminal(monkeypatch)
|
|
421
|
+
path = tmp_path / ("x" * 80) / "store.omni"
|
|
422
|
+
|
|
423
|
+
cli_module.print_error(f"cannot open [qa] store {path}", stderr=stderr)
|
|
424
|
+
|
|
425
|
+
captured = capsys.readouterr()
|
|
426
|
+
text = captured.err if stderr else captured.out
|
|
427
|
+
assert (captured.out if stderr else captured.err) == ""
|
|
428
|
+
assert any(f"[qa] store {path}" in line for line in text.splitlines()), text
|
|
429
|
+
|
|
430
|
+
|
|
362
431
|
def test_rebuild_refuses_a_file_path_with_real_git(tmp_path, monkeypatch, capsys):
|
|
363
432
|
"""`index`/`reindex` accept a FILE, and `git -C <file>` exits 128.
|
|
364
433
|
|
|
@@ -386,4 +455,4 @@ def test_rebuild_refuses_a_file_path_with_real_git(tmp_path, monkeypatch, capsys
|
|
|
386
455
|
with pytest.raises(SystemExit):
|
|
387
456
|
cli_module._rebuild_stores(target, yes=True, slug="https://github.com/test/cg")
|
|
388
457
|
|
|
389
|
-
assert "not the repo root" in capsys.readouterr().out
|
|
458
|
+
assert "not the repo root" in " ".join(capsys.readouterr().out.split())
|
|
@@ -135,3 +135,24 @@ def test_inject_context_cmd_passes_an_explicit_client_through(monkeypatch, clien
|
|
|
135
135
|
command(*bound.args, **bound.kwargs)
|
|
136
136
|
|
|
137
137
|
assert seen == [client]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@pytest.mark.parametrize(
|
|
141
|
+
("argv", "lock_fd"),
|
|
142
|
+
[
|
|
143
|
+
(["_drain-pending", "repo", "7"], 7), # POSIX: the inherited lock
|
|
144
|
+
(["_drain-pending", "repo"], None), # Windows: the drainer locks
|
|
145
|
+
],
|
|
146
|
+
)
|
|
147
|
+
def test_drain_pending_cmd_takes_an_optional_lock_fd(monkeypatch, argv, lock_fd):
|
|
148
|
+
import witan_code.hooks as hooks_module
|
|
149
|
+
|
|
150
|
+
seen = []
|
|
151
|
+
monkeypatch.setattr(
|
|
152
|
+
hooks_module, "drain_pending", lambda checkout, fd: seen.append(fd)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
command, bound, _ = cli.app.parse_args(argv)
|
|
156
|
+
command(*bound.args, **bound.kwargs)
|
|
157
|
+
|
|
158
|
+
assert seen == [lock_fd]
|
|
@@ -200,6 +200,23 @@ def test_a_bracketed_title_is_not_escaped_in_structured_output(capsys):
|
|
|
200
200
|
assert json.loads(capsys.readouterr().out)["title"] == "Symbol table — [local]"
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
@pytest.mark.parametrize("fmt", ["json", "toml", "yaml"])
|
|
204
|
+
def test_symbols_with_no_repo_fails_on_stderr(monkeypatch, capsys, fmt):
|
|
205
|
+
"""A refusal is not a document: stdout stays empty for the parser and the
|
|
206
|
+
exit status says the command did not run."""
|
|
207
|
+
output_module.set_output_format(fmt)
|
|
208
|
+
monkeypatch.setattr(cli_module, "_is_remote", lambda: True)
|
|
209
|
+
monkeypatch.setattr("witan_code.repo.detect", lambda *a, **kw: None)
|
|
210
|
+
|
|
211
|
+
with pytest.raises(SystemExit) as exc:
|
|
212
|
+
cli_module.symbols()
|
|
213
|
+
|
|
214
|
+
assert exc.value.code == 1
|
|
215
|
+
captured = capsys.readouterr()
|
|
216
|
+
assert captured.out == ""
|
|
217
|
+
assert "No repo detected" in captured.err
|
|
218
|
+
|
|
219
|
+
|
|
203
220
|
def test_launcher_sets_output_format_and_forwards_tokens(monkeypatch):
|
|
204
221
|
calls = []
|
|
205
222
|
monkeypatch.setattr(cli_module, "app", lambda tokens: calls.append(tokens))
|