Skip to content

Make --fail-on an enum, now argh compiles its default - #82

Merged
Mpdreamz merged 1 commit into
mainfrom
typed-fail-on
Nov 14, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
typed-fail-on

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

--fail-on is now the SuggestedVersionChange enum. --help lists none|patch|minor|major, and argh rejects any other value. This needs Nullean.Argh 0.30.1.

Prompt summary: argh 0.30.1 shipped the enum default fix from nullean/argh#151 so that assembly-differ's options could be typed. This takes it.

Why

An enum parameter whose default member was not 0 did not compile with argh before 0.30.1 (nullean/argh#75). SuggestedVersionChange.None is 1, so --fail-on was a string with [AllowedValues] and a hand-written Enum.Parse.

What

A typed option

ReportOptions.FailOn is a SuggestedVersionChange that defaults to None. The commands pass it straight to the comparison. Argh matches values case-insensitively, as Enum.Parse did.

diff unchanged

The hidden diff keeps its string --prevent-change and its error for an unknown value, because its output is part of the contract. The characterization snapshots for it do not change.

Verify

mise run test
assembly-differ files old.nupkg new.nupkg --fail-on major   # exit 4 on a breaking change

Only the help snapshots change.

🤖 Generated with Claude Code

@Mpdreamz Mpdreamz added the enhancement An existing capability improved (minor bump) label Nov 14, 2026
--fail-on was a string checked against a list by hand, because argh could
not compile an enum parameter defaulting to a member that is not 0
(nullean/argh#75). Argh 0.30.1 can, so --fail-on is SuggestedVersionChange:
help lists its values and argh rejects others. The hidden diff keeps its
string --prevent-change unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mpdreamz
Mpdreamz merged commit d39beae into main Nov 14, 2026
6 checks passed
@Mpdreamz
Mpdreamz deleted the typed-fail-on branch November 14, 2026 08:52
Mpdreamz added a commit that referenced this pull request Nov 14, 2026
`pull-request --fail-on major` fails the check on a breaking change,
labels it `breaking`, and says in the comment that adding
`breaking-allowed` lets it through. Once someone adds the label, the
next run passes.

**Prompt summary:** The GitHub Action should set the `breaking` label,
and it should also allow a configurable allow label. The flow: a library
author makes a breaking change, assembly-differ detects it, applies
`breaking` and fails. The author applies the allow label, the workflow
runs again, and it succeeds.

## Why
`pull-request` labelled a breaking change but could not hold it back.
Failing on it took `--fail-on` on the comparison step, which knows
nothing about labels, so an intended break failed every run until
someone loosened the workflow.

## What

#### The labels decide the gate
`pull-request` now reads the pull request's labels before it writes
anything. With `--fail-on major`, a `Major` suggestion fails with exit
code `4` unless the pull request has the allow label. The default is
`breaking-allowed`, and `--allow-label` renames it. A change below
`--fail-on` passes as before. The release label is set either way, so
`breaking` stays on the pull request after the break is allowed.

#### The comment says what to do
A blocked change opens the comment with a caution: the check fails, and
adding `breaking-allowed` allows it if the change is intended. An
allowed change gets a note that the label allows it. The console says
the same.

#### Runs without labels
Outside a pull request there are no labels, so `--fail-on` applies as it
does on the other commands. A read-only token, as on a pull request from
a fork, can still read the labels, so the gate works there too; only the
comment and label writes are skipped, with a warning.

## Verify
```bash
mise run test
# PullRequestTests: Fails_a_breaking_change_until_the_allow_label_is_added runs the whole flow against FakeGitHub
```

The workflow has to run on the `labeled` and `unlabeled` pull request
events, so adding the label runs the check again; the README says so,
and the GitHub Action pull request sets it up.

**Stack:** 2 of 2, on top of
[#82](#82).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An existing capability improved (minor bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant