Skip to content

Commit 537d093

Browse files
committed
chore: coderabbit feedback
1 parent a78d5be commit 537d093

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

docs/features/command-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A concise, code-sourced reference for Shiplog commands, flags, and examples. Glo
4242
- Success case: `git shiplog run --service deploy --reason "Smoke test" -- env printf hi`
4343
- Failure case: `git shiplog run --service deploy --status-failure failed -- false`
4444
- Flags: `--service`, `--reason`, `--status-success`, `--status-failure`, `--ticket`, `--region`, `--cluster`, `--namespace`, `--env`, `--dry-run`.
45-
- Notes: captures stdout/stderr to a temporary log that is attached as a git note (skipped if empty) and merges `{run:{...}}` into the JSON trailer via `SHIPLOG_EXTRA_JSON`. `--dry-run` prints the command that would execute and exits without running it or writing a journal entry. See `docs/reference/json-schema.md` for the structured payload.
45+
- Notes: captures stdout/stderr to a temporary log that is attached as a git note (skipped if empty) and merges `{run:{...}}` into the JSON trailer via `SHIPLOG_EXTRA_JSON`. `--dry-run` prints the command that would execute and exits without running it or writing a journal entry. See `docs/features/run.md` for detailed behavior (preview output, exit codes, caveats) and `docs/reference/json-schema.md` for the structured payload.
4646

4747
- `ls [ENV] [LIMIT]`
4848
- Purpose: list recent entries.

docs/features/run.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
# Run Command
22

33
## Summary
4-
`git shiplog run` wraps a shell command, captures its stdout/stderr, and records the execution as a Shiplog journal entry. The command output is saved as a git note, and the structured trailer gains a `run` payload describing the invocation. Use `--dry-run` to preview what would happen without executing the command or writing an entry.
4+
`git shiplog run` wraps a shell command, captures its stdout/stderr, and records the execution as a Shiplog journal entry. Output is saved as a git note, and the structured trailer gains a `run` payload describing the invocation. Use `--dry-run` to preview the command, status, and trailer fields without executing the command or mutating the journal.
55

66
## Usage
77
```bash
8+
# Standard execution (writes to the journal once the wrapped command runs)
89
git shiplog run --service deploy --reason "Smoke test" -- env printf hi
10+
11+
# Dry run: rehearse the invocation without executing or writing an entry
912
git shiplog run --dry-run --service deploy --reason "Smoke test" -- env printf hi
1013
```
1114

12-
- `--service` is required in non-interactive mode (and highly recommended in general).
13-
- Place the command to execute after `--`. All arguments are preserved and logged.
14-
- Successful runs inherit `--status-success` (default `success`); failures use `--status-failure` (default `failed`).
15+
- `--service` is required in non-interactive mode (and strongly recommended for clarity).
16+
- Place the command to execute after `--`; all arguments are preserved and logged.
17+
- Successful executions inherit `--status-success` (default `success`); failures use `--status-failure` (default `failed`).
18+
19+
## Dry Run Mode (`--dry-run`)
20+
- Prints a Bosun-formatted preview (or a plain message when Bosun/TTY styling is unavailable) showing the command that would execute.
21+
- Skips command execution, journal entry creation, and log attachment entirely.
22+
- Exits with status `0` when the dry-run invocation is well formed. Invalid flags, missing `--`, or unknown subcommands surface the same non-zero exit codes as the standard command.
23+
- Deterministic output keeps automation safe while rehearsing deploy playbooks.
1524

16-
## Behavior
17-
- Captures stdout/stderr to a temporary file. When not in boring mode, output is also streamed to your terminal via `tee`.
18-
- `--dry-run` prints the wrapped command, returns exit code 0, and skips execution, journal writes, and log attachment.
19-
- Sets `SHIPLOG_BORING=1` and `SHIPLOG_ASSUME_YES=1` while calling `git shiplog write` so no prompts fire.
20-
- Populates `SHIPLOG_EXTRA_JSON` with:
25+
## Behavior (Standard Runs)
26+
- Captures stdout/stderr to a temporary file. When Bosun is available, output streams through a live preview while still being recorded for notes.
27+
- Sets `SHIPLOG_BORING=1` and `SHIPLOG_ASSUME_YES=1` while delegating to `git shiplog write`, ensuring prompts are bypassed.
28+
- Populates `SHIPLOG_EXTRA_JSON` with a `run` block such as:
2129
```json
2230
{
2331
"run": {
@@ -32,21 +40,34 @@ git shiplog run --dry-run --service deploy --reason "Smoke test" -- env printf h
3240
}
3341
}
3442
```
35-
- Attaches the captured log as a git note under `refs/_shiplog/notes/logs` when the entry is written successfully.
36-
- Returns the wrapped command’s exit code so it can be chained in scripts or CI pipelines.
43+
- Attaches the captured log as a git note under `refs/_shiplog/notes/logs` when an entry is written successfully.
44+
- Returns the wrapped command’s exit code so it can chain cleanly in scripts or CI pipelines.
45+
46+
## Exit Codes
47+
- Dry run
48+
- `0` when the preview succeeds.
49+
- Non-zero for malformed invocations or validation errors.
50+
- Standard run
51+
- Mirrors the wrapped command’s exit status after the journal entry is recorded.
52+
- Propagates Shiplog errors directly if the CLI fails before wrapping the command.
3753

3854
## Options
39-
- `--dry-run`Print the command that would execute, then exit without running it or writing a journal entry.
55+
- `--dry-run`Preview the command and metadata without executing or writing an entry.
4056
- `--env <name>` — Target journal environment (defaults to `SHIPLOG_ENV` or `prod`).
4157
- `--service <name>` — Service/component; required when prompts are disabled.
4258
- `--reason <text>` — Optional free-form description.
43-
- `--status-success <status>` — Status recorded when the command exits 0. Default `success`.
59+
- `--status-success <status>` — Status recorded when the wrapped command exits 0. Default `success`.
4460
- `--status-failure <status>` — Status recorded when the command fails. Default `failed`.
4561
- `--ticket <id>`, `--region <r>`, `--cluster <c>`, `--namespace <ns>` — Override standard write metadata.
4662
- When there is no output, log attachment is skipped and `log_attached=false` is recorded in the trailer.
4763

64+
## Caveats
65+
- Dry runs do not validate connectivity to downstream systems—it only checks CLI argument parsing and policy prerequisites.
66+
- Ensure `perl` is available if you rely on Bosun rendering; otherwise Shiplog falls back to plain text.
67+
4868
## See Also
4969
- `docs/features/write.md`
70+
- `docs/features/command-reference.md`
5071
- `docs/reference/env.md`
5172
- `docs/notes/codex-feedback-on-shiplog.md`
5273
- `docs/reference/json-schema.md`

docs/releases/v0.2.1.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
55
> [!information]
66
> In my haste to release `v0.2.0`, I neglected to add a `--dry-run` mode to `git shiplog run`. This rapid follow-up is to address this oversight.
7-
8-
This maintenance release adds a safe way to rehearse Shiplog runs while keeping the journal untouched.
7+
8+
**Release type:** Feature release
9+
10+
This feature release introduces the new `--dry-run` flag for `git shiplog run`, letting teams rehearse deployments safely without mutating the journal.
911

1012
## ⚓ Highlight
1113

1214
### 🧪 Dry-Run Preview — `git shiplog run --dry-run`
1315

14-
Plan a maintenance step or incident response without firing the actual command. The new `--dry-run` flag formats the invocation, shows what would be recorded, and exits 0 without executing or writing to the journal.
16+
Plan a maintenance step or incident response without firing the actual command. The new `--dry-run` flag formats the invocation, previews exactly what would be logged, and exits 0 without executing or touching the journal.
1517

1618
```bash
1719
$ git shiplog run \
@@ -23,8 +25,8 @@ $ git shiplog run \
2325
```
2426

2527
- No command side effects and no Git notes are created.
26-
- Bosun-enabled terminals receive a styled “Dry Run” card; otherwise the CLI prints the same message once.
27-
- The exit code is always 0, keeping rehearsals script-friendly.
28+
- Bosun-enabled terminals (see the [Bosun CLI styling tool docs](../bosun/overview.md)) receive a styled “Dry Run” card; otherwise the CLI prints the same message once.
29+
- Successful dry runs exit 0 for scripting ease; malformed input or unknown commands still return non-zero.
2830

2931
## 🧭 Upgrade Notes
3032

0 commit comments

Comments
 (0)