Optionally output a unified diff#8
Optionally output a unified diff#8vincentdephily wants to merge 13 commits intocert-manager:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @vincentdephily. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
9fd1b6d to
5e0a794
Compare
|
@vincentdephily could you split this PR into smaller PRs? Also, @ me to get a faster review. |
|
Thanks @inteon, I'll rebase and see if I can split this, maybe separate into a I also have some ongoing work to make the template list configurable again, a more general/flexible version of what #4 offers, I'll file a separate PR afterwards. |
There is no need to special-case handling a single file. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
This reduces memory use by not reading all files upfront. It should parallelize better if we later want to do that. It's shorter and IMHO cleaner. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Signed-off-by: Vincent de Phily <vdephily@redhat.com>
This makes it much easier to fix invalid boilerplate. It required a significant change to the algorithm, as we need to keep track of where the existing template is in the file, as well as the current copyright year. We manually parse comments, but only need to support the kind seen in boilerplates. We enforce having a newline before (if applicable) and after the boilerplate, trading flexibility for consistently and implementation simplicity. I feel the code is overall cleaner. This commit implements the base logic, but commits improving the testing and UX should follow. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
* Move functionality from callers and tests into `NewBoilerplateTemplate()`. * Unittest `LoadTemplates()` directly instead of running bitrottable checks on template files. * Simplify code and improve comments a bit. Short-term, this makes upcoming unittests easier. Longer-term, this prepares for supporting user-suplied templates, and is IMHO more maintainable. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
* Add unittest for template parsing. * Rename `BoilerplateTemplate` to `Template` and other small readability tweaks. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Otherwise the patch would create files with mixed newline types. Before the `-patch` feature, the problem was sidestepped by using LF newlines everywhere internally. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
Signed-off-by: Vincent de Phily <vdephily@redhat.com>
This is now more thoroughly tested using standard go tests. Signed-off-by: Vincent de Phily <vdephily@redhat.com>
…g descriptions Signed-off-by: Vincent de Phily <vdephily@redhat.com>
5e0a794 to
b0caf36
Compare
|
@inteon Here's the reworked branch:
It's still a large patch, but it's a bit more focused. The main commit is the |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR adds a
--patchflag, which outputs a unified diff of the changes needed to fix the boilerplate, instead of just listing the files with issues. So that a user can just runboilersuite --patch . | patch -p0and then review the changes before committing.The core changes are done and explained in 486a937. The other commits are refactorings, unittests, error strings, comments, docs, and a bugfix. Hopefully this makes the code more maintainable overall.