Skip to content

Commit 1ddefa7

Browse files
authored
apply: drop --dry-run; it always validates before publishing (#299)
`ucode apply --dry-run` validated and previewed without writing — but `apply` already validates unconditionally before it publishes, shows the summary, and confirms, so the flag added a mode with no distinct value. `ucode setup` only ever writes a valid manifest; the one case worth guarding is a hand-edited managed-settings.json, and that is caught by the normal validation `apply` runs regardless. Removes the `--dry-run` option from `apply_cmd` and the `is_dry_run()` early-out in `apply_command`. The confirmation prompt still gates every publish, and the manifest is still validated first (`ucode apply` on an invalid hand-edit fails before anything reaches the workspace). README updated. Unrelated dry-run paths are untouched: `ucode setup --dry-run` (walk the flow without writing) and `ucode --dry-run` (launch against the last saved config) keep their flags. Tests: dropped test_dry_run_validates_without_publishing (behaviour gone); the option-declaration test now asserts `--dry-run` is absent and `--yes` present. Co-authored-by: Isaac
1 parent 62c5536 commit 1ddefa7

4 files changed

Lines changed: 12 additions & 29 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ Once the manifest looks right, publish it:
206206
# Validate, show what would change, and ask before publishing.
207207
ucode apply
208208

209-
# Preview without publishing.
210-
ucode apply --dry-run
211-
212209
# Publish without the confirmation prompt (for CI).
213210
ucode apply --yes
214211
```

src/ucode/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,13 +2345,13 @@ def apply_cmd(
23452345
bool,
23462346
typer.Option("--yes", "-y", help="Publish without the confirmation prompt."),
23472347
] = False,
2348-
dry_run: Annotated[
2349-
bool,
2350-
typer.Option("--dry-run", help="Validate and preview without publishing."),
2351-
] = False,
23522348
) -> None:
2353-
"""Publish this workspace's managed coding config (workspace admins only)."""
2354-
set_dry_run(dry_run)
2349+
"""Publish this workspace's managed coding config (workspace admins only).
2350+
2351+
Always validates the manifest before publishing (and shows what would change, then confirms), so
2352+
there is no separate dry-run: `ucode setup` only ever writes a valid manifest, and a
2353+
hand-editing admin sees any error here before anything reaches the workspace.
2354+
"""
23552355
# See the `setup` callback: `typer.Exit` subclasses RuntimeError, so it must be raised after
23562356
# the try block or the handler below would report a successful exit as an error.
23572357
try:

src/ucode/managed_wizard.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,10 +1085,6 @@ def apply_command(*, yes: bool = False) -> int:
10851085
print_note("Nothing was published.")
10861086
return 1
10871087

1088-
if is_dry_run():
1089-
print_success("Dry run: the config was validated but not published.")
1090-
return 0
1091-
10921088
if existing is None:
10931089
with spinner("Publishing the managed config..."):
10941090
published, publish_reason = create_coding_agent_config(workspace, token, payload)

tests/test_managed_wizard.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,18 +1610,6 @@ def test_existing_config_without_a_resource_name_is_an_error(self):
16101610
with pytest.raises(RuntimeError, match="resource name"):
16111611
self._run(get_managed_config=lambda *a, **k: ({"enabled_agents": {}}, None))
16121612

1613-
def test_dry_run_validates_without_publishing(self, monkeypatch):
1614-
managed_setup_mod.save_managed_settings(WORKSPACE, self.MANIFEST)
1615-
monkeypatch.setattr(config_io_mod, "_dry_run", True)
1616-
created = {"called": False}
1617-
1618-
def fake_create(*a, **k):
1619-
created["called"] = True
1620-
return {}, None
1621-
1622-
assert self._run(create_coding_agent_config=fake_create) == 0
1623-
assert created["called"] is False
1624-
16251613

16261614
class TestPublishFailureMessages:
16271615
"""The server's error codes, turned into something an admin can act on."""
@@ -1678,12 +1666,14 @@ def test_apply_is_registered(self):
16781666
assert result.exit_code == 0
16791667
assert "apply" in result.output
16801668

1681-
def test_apply_declares_yes_and_dry_run(self):
1682-
# Asserted on the declared options rather than rendered help, which Rich ellipsizes at
1683-
# narrow terminal widths (see test_setup_help_lists_from_file).
1669+
def test_apply_declares_yes_and_no_dry_run(self):
1670+
# `--dry-run` was removed: apply always validates before publishing, so a separate
1671+
# validate-only mode is redundant. Asserted on declared options rather than rendered help,
1672+
# which Rich ellipsizes at narrow widths (see test_setup_help_lists_from_file).
16841673
command = typer.main.get_command(app).commands["apply"] # type: ignore[attr-defined]
16851674
declared = {opt for param in command.params for opt in param.opts}
1686-
assert {"--yes", "--dry-run"} <= declared
1675+
assert "--yes" in declared
1676+
assert "--dry-run" not in declared
16871677

16881678
def test_apply_error_exits_nonzero_with_a_message(self):
16891679
with patch.object(cli_mod, "apply_command", side_effect=RuntimeError("no config authored")):

0 commit comments

Comments
 (0)