Skip to content

Fix #340: git-commit @file route for multi-line messages#343

Merged
fdaviddpt merged 2 commits into
masterfrom
fix/git-commit-payload-route-340
Jun 26, 2026
Merged

Fix #340: git-commit @file route for multi-line messages#343
fdaviddpt merged 2 commits into
masterfrom
fix/git-commit-payload-route-340

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Context

git-commit:::MSG[:::PATH...] took the message as a single colon-CLI token, so any subject+body commit dropped to raw git commit -F file — which skips the op's auto Co-Authored-By trailer and forced a follow-up --amend (#340). The @file payload route already existed for edit/replace/etc., and the registry did build an entry for git-commit — but the field-name parser leaked the syntax brackets (MSG[, PATH...]), so git-commit:@- 404'd with missing 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 rewritten parts flow straight into _resolve_custom_opcommit.py. The only bug was the bracket-leaking field parse.

Change

Generalized the @file field parser (benefits any preset, not git-commit-special-cased):

  • _fields_from_syntax now emits (name, optional, variadic) specs — strips [ ] ..., marks a trailing [...] group optional and a ... token variadic.
  • _at_file_to_parts skips absent optional fields and expands a variadic payload list into multiple positional args.
  • git-commit syntax relabeled MESSAGE[:::PATHS...] → clean payload keys message (required) + paths (optional list). Trailer appended on both the colon-CLI and @file routes.

Now works:

printf "message = '''Subject\n\nMulti-line body.'''\npaths = [\"a.txt\",\"b.txt\"]\n" \
  | ./supertool 'git-commit:@-'

Multi-line body preserved, paths staged, Co-Authored-By auto-appended — no git commit -F + --amend dance. (This PR's own commit was made with git-commit:@-.)

Unchanged

  • Colon-CLI one-liner git-commit:::MESSAGE (positional dispatch).
  • Builtin edit/replace/replace_dry/replace_lines/paste/vim @file routes (hardcoded defaults).
  • _at_file_fields stays name-only for the truthiness / batch sub-op callers; new _at_file_specs carries the optional/variadic flags.

Tests

238 passed across the touched suites. New TestAtFileOptionalVariadic (optional skip, list→multi-part, scalar, missing-required) + updated _fields_from_syntax spec-shape assertions. Docs: docs/presets/git.md row + CHANGELOG.

Closes #340

🤖 Generated by Max

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>
@fdaviddpt fdaviddpt merged commit 5c1a914 into master Jun 26, 2026
12 checks passed
@fdaviddpt fdaviddpt deleted the fix/git-commit-payload-route-340 branch June 26, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git-commit:::MSG is single-line only — multi-line body forces raw git commit, losing the co-author trailer

1 participant