Fix #340: git-commit @file route for multi-line messages#343
Merged
Conversation
The @file payload parser leaked syntax brackets into field names (git-commit:::MSG[:::PATH...] -> fields msg[, path...]), so git-commit:@- 404'd with "missing required field 'msg['" and any real subject+body commit had to drop to raw git commit -F -- which skips the op's auto Co-Authored-By trailer and forced a follow-up --amend. Generalize the field parser: a token in a trailing [...] group is optional, a ... token is variadic (payload list expands to multiple positional args). git-commit syntax relabeled MESSAGE[:::PATHS...] so the payload keys are message (required) + paths (optional list); the trailer is appended on both routes. Colon-CLI one-liner and the builtin edit/replace/paste/vim @file routes are unchanged. Co-Authored-By: Max <noreply>
… null-safe variadic Review follow-ups on the #340 generalization. - _fields_from_syntax now returns [] when any derived field name is not a clean identifier, so a syntax string carrying inline prose/punctuation (git-resolve: comma list + parenthesized notes) no longer registers a falsely-named, non-functional @file route. The registry is now actually clean across all presets, as the #340 docstring claimed. - Optionality tracked by [ ] bracket depth instead of a one-way seen-open flag, so a required field after a closed optional group stays required. - Variadic expansion drops null values/elements, so paths:null / paths:[] omit cleanly rather than emitting a literal "None" positional arg. Tests: git-resolve real syntax -> [], middle-optional, empty/null paths. Co-Authored-By: Max <noreply>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
git-commit:::MSG[:::PATH...]took the message as a single colon-CLI token, so any subject+body commit dropped to rawgit commit -F file— which skips the op's autoCo-Authored-Bytrailer and forced a follow-up--amend(#340). The@filepayload route already existed foredit/replace/etc., and the registry did build an entry for git-commit — but the field-name parser leaked the syntax brackets (MSG[,PATH...]), sogit-commit:@-404'd withmissing required field 'msg['.The dispatcher was never the blocker: in a repo with config, git-commit is in
config["ops"], so the @file branch fires and the rewrittenpartsflow straight into_resolve_custom_op→commit.py. The only bug was the bracket-leaking field parse.Change
Generalized the
@filefield parser (benefits any preset, not git-commit-special-cased):_fields_from_syntaxnow emits(name, optional, variadic)specs — strips[]..., marks a trailing[...]group optional and a...token variadic._at_file_to_partsskips absent optional fields and expands a variadic payload list into multiple positional args.MESSAGE[:::PATHS...]→ clean payload keysmessage(required) +paths(optional list). Trailer appended on both the colon-CLI and@fileroutes.Now works:
Multi-line body preserved, paths staged,
Co-Authored-Byauto-appended — nogit commit -F+--amenddance. (This PR's own commit was made withgit-commit:@-.)Unchanged
git-commit:::MESSAGE(positional dispatch).edit/replace/replace_dry/replace_lines/paste/vim@file routes (hardcoded defaults)._at_file_fieldsstays name-only for the truthiness / batch sub-op callers; new_at_file_specscarries the optional/variadic flags.Tests
238 passedacross the touched suites. NewTestAtFileOptionalVariadic(optional skip, list→multi-part, scalar, missing-required) + updated_fields_from_syntaxspec-shape assertions. Docs:docs/presets/git.mdrow + CHANGELOG.Closes #340
🤖 Generated by Max