My application has some specific needs which require me to patch the library in a few places. The patches are easy (less than a dozen lines), but since they are specific to our use case and not bugs.
I'd like to be able to update when new versions of the library itself are released, which would overwrite our changes in our Git repository.
I need a way to ensure our patches are always applied before pushing the updated library to a production server. Since the changes are very small, it wouldn't be an issue to apply them manually.
How can I ensure my patches to third party code are applied in our repository when updating the third party code?
Create a repository for tracking the third-party code, and put your patches in a separate branch. When you need the latest release fetch the changes and rebase your branch.
$ git clone --origin github https://github.com/tinymce/tinymce.git $ cd tinymce/ $ git remote add origin [email protected]:tinymce
Then make your patches and push to your repository:
$ git commit -m "my patches to tinymce" $ git push --set-upstream origin master
At this point your repository looks like this:
(0) --- (1) --- ... (n) --- (X) | master
Where X is your patch.
Now set a branch to fetch new revisions from the github remote:
$ git branch tinymce_import github/master $ git checkout tinymce_import $ git pull --ff-only
So your repository becomes like this (
git branch is smart enough to use as the origin the last revision in the github remote):
master | +----- (X) | (0) --- (1) --- ... (n) --- (n+1) --- ... (n+m) | tinymce_import
At last rebase your master branch on tinymce_import:
$ git checkout master $ git rebase tinymce_import master | +----- (X) | (0) --- (1) --- ... (n) --- (n+1) --- ... (n+m) | tinymce_import
If you storing TinyMCE in a Git repo, then you could use a Git
post-commit-hook to perform the patches after you get a new version of TinyMCE (then commit those patches).
The workflow would be something like:
[get new version of TinyMCE] ["git commit -a" to update all tracked files] [post-commit-hook patches TinyMCE] ["git commit -a" to pick up all of the changes from the patches]
©2020 All rights reserved.