feat: add --format=md and --format=llm to mr:files and mr:diff#316
Merged
feat: add --format=md and --format=llm to mr:files and mr:diff#316
Conversation
Wire MergeRequestFilesResult and MergeRequestDiffResult into the formatter architecture so mr:files and mr:diff benefit from LlmFormatter (XML/CDATA output) and MarkdownFormatter alongside the existing json and text formats. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r:files and mr:diff Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
MergeRequestFilesResultandMergeRequestDiffResultinAbstractFormatter::format()so the formatter dispatch covers these typesformatMergeRequestFiles()andformatMergeRequestDiff()inLlmFormatter(XML with CDATA diff) andMarkdownFormatter(bullet list + fenced diff block)json_encodebranches inGetFilesandGetDiffwith$this->writeFormatted(), so all four formats (text,json,md,llm) are handled uniformly--formatoption descriptions to list all supported valuesJsonFormatterrequired no changes — it serializes anyResultInterfaceviajson_encode.Closes #312.
Test plan
vendor/bin/phpstan analyse src— no errorsvendor/bin/phpcs src— no errorsvendor/bin/phpunit— all 122 tests passbin/drupalorg mr:files --format=llm <nid>— emits<drupal_context>XMLbin/drupalorg mr:diff --format=llm <nid>— emits<drupal_context>XML with CDATA diffbin/drupalorg mr:files --format=md <nid>— emits Markdown bullet listbin/drupalorg mr:diff --format=md <nid>— emits Markdown with fenced diff blockbin/drupalorg mr:files --format=json <nid>— still worksbin/drupalorg mr:diff --format=json <nid>— still works🤖 Generated with Claude Code