-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Is your feature request related to a problem? Please describe.
I have an application with a json configuration file. Said configration file is by default "large" containing around 100 lines. The configuration exists in the repository of the application in its default state, but the program will on the first run copy the configuration to the user's home directory as a dotfile, and use that during runtime, thus making it user configurable. The configuration in the repository is basically used as a reference with default values.
Sometimes there are changes in the reference configuration, for example adding a field, or changing a default value. I would like said changes to be reflected in the user's configuration file as well. A way could be to reset their configuration file to the updated reference file, but then the users would lose their custom additions. This is basically what we do now. The users have to do the "migration" manually.
So I thought, what if I could do a "git apply" with the diff between the reference config and the user's config, BUT the apply only does additions and changes (no removals).
Describe the solution you'd like
There is added options to disable remove, add, change when patching. The function signature could for example be
patch(diff_result, destination, in_place=False, remove=True, add=True, change=True)Describe alternatives you've considered
I could implement a "migration" system with code, which is something I have done for another project. That would have give me a lot of flexibility in upgrading the user's config files without messing with their stuff. The problem is that this project is highly colloborative, and I want the reference file to remain easy to change (just update the json file in the repo), without needing to code anything.
Additional context
I have already experimented locally with the changes and it worked fine