gabriel / muse public
feat patch show task/supercharge-show #1 / 1
AI Agent gabriel · 161 days ago · Apr 18, 2026 · Diff

feat(show): add elapsed_ms/exit_code JSON envelope, fix double-print error bug

- Add import time + start_time/_elapsed() closure in run() - Add _emit_error() closure: emits structured JSON to stdout (--json) or plain text to stderr (text mode) — consistent with rev-list, rev-parse, shortlog pattern - Fix double-print bug: commit-not-found with --json no longer also prints plain-text ❌ to stderr; _emit_error() handles both paths in one place - Inject elapsed_ms + exit_code into all JSON success payloads - Update module docstring with full JSON schema and error envelope - Add tests/test_cmd_show_hardening.py: 16 tests covering elapsed_ms/exit_code on success, structured error JSON on stdout, no duplicate stderr, envelope fields on --no-delta/--manifest/--no-stat paths - Fix test_format_flag_produces_same_as_json_flag: exclude elapsed_ms from equality comparison (timing differs between separate invocations)

sha256:3c688506f4d9cac48a6a2eb9589c1ec5da6879d4bcdd3442e64d3a0a39091f5b sha
+33 ~3 symbols
sha256:531d19e228b4451b96cbfbbeac86867a4e21b252f391cbfd62d35ae31755b218 snapshot
+33
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 36 symbols
~ tests/test_cmd_show_hardening.py .py 32 symbols added
+ TestElapsedAndExitCode class class TestElapsedAndExitCode L78–126
+ test_manifest_json_has_envelope method method test_manifest_json_has_envelope L114–119
+ test_no_delta_json_has_envelope method method test_no_delta_json_has_envelope L107–112
+ test_no_stat_json_has_envelope method method test_no_stat_json_has_envelope L121–126
+ test_success_json_elapsed_ms_is_float method method test_success_json_elapsed_ms_is_float L85–90
+ test_success_json_elapsed_ms_non_negative method method test_success_json_elapsed_ms_non_negative L92–95
+ test_success_json_exit_code_is_zero method method test_success_json_exit_code_is_zero L102–105
+ test_success_json_has_elapsed_ms method method test_success_json_has_elapsed_ms L79–83
+ test_success_json_has_exit_code method method test_success_json_has_exit_code L97–100
+ TestErrorJson class class TestErrorJson L134–183
+ test_commit_not_found_error_json_exit_code_nonzero method method test_commit_not_found_error_json_exit_code_nonzero L162–167
+ test_commit_not_found_error_json_has_elapsed_ms method method test_commit_not_found_error_json_has_elapsed_ms L155–160
+ test_commit_not_found_json_has_ref_key method method test_commit_not_found_json_has_ref_key L141–144
+ test_commit_not_found_json_to_stdout method method test_commit_not_found_json_to_stdout L135–139
+ test_commit_not_found_no_duplicate_stderr method method test_commit_not_found_no_duplicate_stderr L146–153
+ test_invalid_format_exits_1 method method test_invalid_format_exits_1 L169–171
+ test_invalid_format_with_json_flag_emits_error_json method method test_invalid_format_with_json_flag_emits_error_json L173–183
+ TestRequiredKeysUpdated class class TestRequiredKeysUpdated L191–219
+ test_all_required_keys_present method method test_all_required_keys_present L214–219
+ _assert_error_json function function _assert_error_json L62–70
+ _commit function function _commit L44–45
+ _invoke function function _invoke L31–37
+ _show function function _show L40–41
+ CliRunner import import CliRunner L21–21
+ InvokeResult import import InvokeResult L21–21
+ annotations import import annotations L13–13
+ json import import json L15–15
+ os import import os L16–16
+ pathlib import import pathlib L17–17
+ pytest import import pytest L19–19
+ repo function function repo L49–59
+ runner variable variable runner L23–23
~ muse/cli/commands/show.py .py 1 symbol added, 1 symbol modified
+ time import import time L84–84
~ run
← Older Oldest on task/supercharge-show
All commits
Newer → Latest on task/supercharge-show

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:3c688506f4d9cac48a6a2eb9589c1ec5da6879d4bcdd3442e64d3a0a39091f5b --body "your comment"