Skip to content

[ChangesReporting] Fix total changed result on --no-diffs on JsonOutputFormatter - #7807

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-total-changed
Jan 5, 2026
Merged

[ChangesReporting] Fix total changed result on --no-diffs on JsonOutputFormatter#7807
TomasVotruba merged 1 commit into
mainfrom
fix-total-changed

Conversation

@samsonasik

@samsonasik samsonasik commented Jan 5, 2026

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9582

Even with --no-diffs, the total files changed should still be shown, just no diff to be shown.

With a 1 file to be changed, it shows:

Before

➜  rector-src git:(main) ✗ ./bin/rector process src/Application/FileProcessor.php --output-format=json --no-diffs --dry-run

{
    "totals": {
        "changed_files": 0,
        "errors": 0
    }
}

After

➜  rector-src git:(fix-total-changed) ./bin/rector process src/Application/FileProcessor.php --output-format=json --no-diffs --dry-run

{
    "totals": {
        "changed_files": 1,
        "errors": 0
    }
}

@samsonasik

Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @peterfox

@samsonasik samsonasik changed the title [ChangesReporting] Fix total changed result on JsonOutputFormatter [ChangesReporting] Fix total changed result on --no-diffs on JsonOutputFormatter Jan 5, 2026
@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

@peterfox

peterfox commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Amazing @samsonasik I was looking at this, my fix was way more converluted 😄. Thank you so much

@TomasVotruba
TomasVotruba merged commit a5cdd61 into main Jan 5, 2026
58 checks passed
@TomasVotruba
TomasVotruba deleted the fix-total-changed branch January 5, 2026 13:32
@TomasVotruba

Copy link
Copy Markdown
Member

LGTM 👍

@peterfox

peterfox commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

The only thing I will add is, the way the formatter currently works, you lose the "changed_files" part of the JSON. Some might expect to still see this if the --no-diffs flag is used

    "changed_files": [
        "some/file.php"
    ],

@TomasVotruba

Copy link
Copy Markdown
Member

@peterfox Seems legit. Could you make a PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

--output-format=json && --no-diffs shows 0 files changed despite applying changes

3 participants