fix(changelog): fall through to the next parser when a commit field is missing - #1600
fix(changelog): fall through to the next parser when a commit field is missing#1600YuriNachos wants to merge 1 commit into
Conversation
…s missing
When a commit parser specified both `field` and `pattern` and the named
field could not be resolved on a commit (e.g. `remote.pr_labels` on a
local / non-PR commit where `remote` is None), `Commit::parse` aborted
the whole parser chain with `AppError::FieldError`. Later catch-all
parsers were never tried, so the commit was silently dropped from the
changelog ("N commit(s) were skipped due to field error(s)").
The field resolution collapsed two different situations into the same
`None`: a genuinely missing field (`tera::dotted_pointer` returned
`None`) and a present-but-`Value::Object` field (mapped to `None` by the
`and_then`). Both hit the `None =>` arm, which returned from the entire
`parse()`.
Distinguish the two with a single `dotted_pointer` lookup
(`field_present = field_value.is_some()`). In the `None =>` arm, a
present `Value::Object` field still returns the identical `FieldError`
(message text unchanged), while a genuinely missing field skips only
that parser so the rest of the chain can still match the commit.
Fixes orhun#1598.
Signed-off-by: Yurii Chukhlib <yurii.chukhlib@viber.com>
5b3ca31 to
3a63572
Compare
|
Re-triggered CI. For the record, the red Every |
|
The "Test suite" check is red only on the "Upload reports to codecov" step (codecov-action in TOKENLESS fork-upload mode, exited 1 with CC_FAIL_ON_ERROR). The actual Rust test run is green — 0 failures across the suite; Check / Lints / Doctests / Test fixtures all pass. This is an intermittent codecov tokenless-upload infra flake unrelated to the parser-fallthrough change. Rerunning the job (maintainer) or a push re-trigger should clear it. |
|
A quick check-in on this one: the fall-through behaviour matches what #1598 described — a local commit with |
Closes #1598.
Problem
When a commit parser references a field that is genuinely absent on a commit (e.g.
remote.pr_labelson a local / non-PR commit whereremoteisNone), the parser returnedFieldErrorand aborted the whole parse — so a single field-based parser could prevent any later (catch-all) parser from grouping the commit. Reported in #1598: a local commit gets skipped by the commit parsers if one of them looks for a field that does not exist on it.Fix
Distinguish a missing field from a present-but-unsupported-type field:
Nonebecause the path is absent → skip only this field criterion and let the rest of the parser (and the remaining parsers) decide;Value::Object) → still error, exactly as before.So a local commit no longer aborts the chain when a parser looks for
remote.pr_labels; the catch-all parser can still group it.Test
parse_commit_missing_field_falls_through_to_next_parser— a commit withremote = Noneand two parsers (fieldremote.pr_labels, then a catch-all) now groups via the catch-all instead of erroring. The existingparse_commit_field(present-but-Object→ error) still passes, preserving that contract.cargo test -p git-cliff-core commit::test→ 9 passed;cargo clippy --tests -D warningsclean.