Skip to content Skip to sidebar Skip to footer

Maintaining Custom Patches On Third Party Code

I'm building a web application that uses a third party JavaScript library (TinyMCE). My application has some specific needs which require me to patch the library in a few places. T

Solution 1:

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.

For example:

$ git clone --origin github https://github.com/tinymce/tinymce.git$ cd tinymce/$ git remote add origin git@myrepo.example.org: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

Solution 2:

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:

[getnew version of TinyMCE]
["git commit -a" toupdateall tracked files]
[post-commit-hook patches TinyMCE]
["git commit -a" to pick up allof the changes from the patches]

Post a Comment for "Maintaining Custom Patches On Third Party Code"