在第三方代码上维护自定义修补程序 [英] Maintaining custom patches on third party code

查看:142
本文介绍了在第三方代码上维护自定义修补程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用第三方JavaScript库(TinyMCE)的Web应用程序。

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. The patches are easy (less than a dozen lines), but since they are specific to our use case and not bugs.

我希望能够更新时间新版本的库本身已经发布,这将覆盖我们在Git存储库中的更改。

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?

推荐答案

创建一个用于跟踪第三方代码的存储库,并将您的补丁放在一个单独的分支中。当您需要最新版本时,可以获取更改并 rebase 您的分支。

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 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这一点你的存储库看起来像这样:

At this point your repository looks like this:

(0) --- (1) --- ... (n) --- (X)
                             |
                           master

其中X是你的补丁。

现在设置一个分支来从 github 远程获取新版本:

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

所以你的存储库就像这样( git branch 足够聪明,可以用作 github 远程中最后一个版本的原点) :

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

最后在tinymce_import上修改 master 分支:

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

这篇关于在第三方代码上维护自定义修补程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆