Skip to content

Commit ad6723b

Browse files
authored
Merge pull request #11 from flyingrobots/release/v0.2.1
release/v0.2.1
2 parents b4ffd6a + 537d093 commit ad6723b

File tree

3 files changed

+79
-14
lines changed

3 files changed

+79
-14
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# 🚢🪵 Shiplog `v0.2.1` – Dry Run
2+
3+
> 🫲 ***ALL HANDS ON DECK!*** 🫱
4+
5+
> [!information]
6+
> 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+
**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.
11+
12+
## ⚓ Highlight
13+
14+
### 🧪 Dry-Run Preview — `git shiplog run --dry-run`
15+
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.
17+
18+
```bash
19+
$ git shiplog run \
20+
--dry-run \
21+
--service deploy \
22+
--reason "Canary toggle" \
23+
-- env ./scripts/flip-canary staging
24+
ℹ️ shiplog run --dry-run: would execute: env ./scripts/flip-canary staging
25+
```
26+
27+
- No command side effects and no Git notes are created.
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.
30+
31+
## 🧭 Upgrade Notes
32+
33+
- No trailer changes or schema updates
34+
- Existing automation keeps working.
35+
- New dry-run behavior is documented in `docs/features/run.md` and the command reference so teams can adopt it immediately.
36+
- Tests covering both the preview path and the standard execution flow run in the Dockerized Bats matrix.
37+
38+
## 🚦Please, Enjoy
39+
40+
Why are you still reading this when you could be downloading `v0.2.1`?!
41+
42+
When you want confidence before the real maneuver: **Shiplog** now lets you practice the tack ⛵️ before committing it to the log.
43+
44+
🚢🪵

0 commit comments

Comments
 (0)