-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meta: Single git commits per rector rule #8898
Comments
Thanks for proposal. We've talked about such a feature for couple year now and it would be welcomed 👍
I think the It could also get matrix of rule class + applied on files and run Rector only on those files, to make the run fast. I'm curious about proof of concept now :) |
With
So indeed only feature number 2 is missing, executing a single rule! -> #8899. |
I've built a shell script that creates a single git commit for each rule that rector wants to apply: https://github.com/mogic-le/rector-single-commit. An resulting example commit log:
The only thing bothering me is that the commit messages are not very helpful; the rule classes are better than nothing but not optimal. Should rector rules themselves contain a docblock that can then be used as commit message, or do you deem that out of scope for rector? The rules overview has human readable descriptions of rules: https://github.com/rectorphp/rector-src/blob/2.0.3/build/target-repository/docs/rector_rules_overview.md?plain=1 |
I've added support for reading messages from .txt files. The git log looks better now:
|
I think the commit messages should indicate that they are created with rector, e.g. by starting with |
The full rule class names are in the long commit message. |
I'll close this issue since we have a solution now. |
Feature Request
When upgrading old code bases, rector currently generates a single diff with changes of all rules.
For a more readable and reviewable git history, it is beneficial to do commits for each single rector rule applied.
Integrating automated git commits is currently (v1.2.10) not possible and deemed out of scope: #8505.
Unfortunately, it is also not possible to automate this process with rector.
Possible automation
If rector would provide the necessary features, it would be possible to automate this process:
1. List of all relevant rules
Currently it is possible to get a list of the short names of all applying rules:
Unfortunately, this short names do not help very much, since we need the full class in the configuration file.
rector
would at least need a way to obtain the full names of the applied rules. Ideally, it would have a separate command that does not generate any diff output, but simply lists the full names of the relevant rules.2. Run rector for a single rule
This is currently only possible by modifying the
rector.php
configuration file.A feature request for an option/parameter #7366 was rejected because short rule names are ambiguous.
When passing full class names, it should not be a problem to find the rule and apply only that.
New feature request: #8899.
3. Create a commit
When 1 and 2 are available, creating commits would be easily possible with external scripts. This does not need to be part of rector.
Missing features
What do you think? Would that be a feasible approach to this problem?
Would the separate command to list applying rules be better, or should we go the option-to-list-full-rule-names-in-process route?
The text was updated successfully, but these errors were encountered: