Commit f0a5047
changelog: switch prepare-artifact bool CLI params to bool? (#3410)
* changelog: switch prepare-artifact bool CLI params to bool?
The `changelog prepare-artifact` command exposed `isFork`, `canCommit`,
and `maintainerCanModify` as plain `bool` parameters. The Argh CLI
framework treats `bool` as a presence-only switch — `--flag` sets true,
omission leaves false. There is no `--flag <value>` form.
When `elastic/docs-actions` shelled `--can-commit "$CAN_COMMIT"` into
this command (where `$CAN_COMMIT` was the string "true" or "false"),
the parser took the bare `--can-commit` as "true" and silently dropped
the literal "false" as a stray positional. Every fork PR ended up with
`can_commit: true` in the artifact metadata, which then routed the
apply step into the commit-and-push branch where it failed on a
detached-HEAD push.
This commit changes the three boolean parameters to `bool?` so:
- Argh now generates `--[no-]flag` pairs for each one. `--can-commit`
sets true, `--no-can-commit` sets false, omission leaves null. The
`--help` output makes this explicit.
- Callers that want to express "explicitly false" have a correct
syntax to do so instead of the silently-broken `--flag false`.
- The service coerces `null` → `false` when writing
`ChangelogArtifactMetadata`, so an omitted flag never grants
commit permission to the downstream apply step (fail closed).
Behaviour summary at the CLI:
Before After
------------------- -------------------------
--can-commit --can-commit → true
(omitted) --no-can-commit → false
--can-commit false (omitted) → false (null → false)
The companion workflow fix in elastic/docs-actions#172 stops emitting
`--flag <value>` patterns in the first place and only appends the
affirmative flag when the upstream string equals "true".
Tests:
- New PrepareArtifact_NullableBoolsUnspecified_CoerceToFalseInMetadata
asserts the fail-closed null → false coercion, which is the
contract the apply step relies on.
- Existing fork-fields tests still cover the explicit true/false paths
(bool → bool? is an implicit conversion at the call sites).
Verified with the AOT binary against a fixture staging dir:
`docs-builder changelog prepare-artifact --is-fork --no-can-commit
--maintainer-can-modify ...` writes
`is_fork: true, can_commit: false, maintainer_can_modify: true` as
expected.
Co-authored-by: Cursor <cursoragent@cursor.com>
* changelog: regenerate cli-schema.json after bool? switch
The previous commit moved the bool→bool? rationale into a regular
`//` comment block sitting between the XML `<param>` lines and the
method declaration. That terminated the XML doc comment group for the
schema source-generator, which then dropped every param summary for
this command and broke the `Check CLI schema is up to date` CI step.
- Inline the explanation into the existing `<remarks>` block as a
`<para>`, restoring the unbroken XML doc group above the method.
- Regenerate `docs/cli-schema.json` so it reflects the bool? CLI
surface: the three flags now serialize with the updated summaries
and `defaultValue: "default"` (nullable default) instead of `"false"`.
No behaviour change beyond the previous commit; this just makes the
schema check pass again.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent a7cf57b commit f0a5047
5 files changed
Lines changed: 68 additions & 19 deletions
File tree
- docs
- src
- services/Elastic.Changelog/Evaluation
- tooling/docs-builder/Commands
- tests/Elastic.Changelog.Tests/Evaluation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3394 | 3394 | | |
3395 | 3395 | | |
3396 | 3396 | | |
3397 | | - | |
| 3397 | + | |
3398 | 3398 | | |
3399 | 3399 | | |
3400 | 3400 | | |
| |||
3452 | 3452 | | |
3453 | 3453 | | |
3454 | 3454 | | |
3455 | | - | |
3456 | | - | |
| 3455 | + | |
| 3456 | + | |
3457 | 3457 | | |
3458 | 3458 | | |
3459 | 3459 | | |
3460 | 3460 | | |
3461 | 3461 | | |
3462 | 3462 | | |
3463 | | - | |
3464 | | - | |
| 3463 | + | |
| 3464 | + | |
3465 | 3465 | | |
3466 | 3466 | | |
3467 | 3467 | | |
3468 | 3468 | | |
3469 | 3469 | | |
3470 | 3470 | | |
3471 | | - | |
3472 | | - | |
| 3471 | + | |
| 3472 | + | |
3473 | 3473 | | |
3474 | 3474 | | |
3475 | 3475 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
88 | | - | |
| 92 | + | |
89 | 93 | | |
90 | | - | |
91 | | - | |
| 94 | + | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | | - | |
20 | | - | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1401 | 1401 | | |
1402 | 1402 | | |
1403 | 1403 | | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1404 | 1415 | | |
1405 | 1416 | | |
1406 | 1417 | | |
| |||
1409 | 1420 | | |
1410 | 1421 | | |
1411 | 1422 | | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1415 | 1426 | | |
1416 | 1427 | | |
1417 | 1428 | | |
| |||
1427 | 1438 | | |
1428 | 1439 | | |
1429 | 1440 | | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
1433 | 1444 | | |
1434 | 1445 | | |
1435 | 1446 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
152 | 180 | | |
153 | 181 | | |
154 | 182 | | |
| |||
0 commit comments