如何以干净的方式分叉现有的 Meteorite 包?

问题描述:

我正在尝试找出在项目中在 Atmosphere 上分叉现有包的最佳/最干净的方法.我遇到过一些现有包需要修改的情况,我不得不将它分叉.

I'm trying to figure out the best/cleanest way to fork an existing package on Atmosphere within a project. I encountered a few occasions where an existing package needed some modifications and I was forced to fork it.

据我所知,存在以下选项.不幸的是,所有这些都有自己的问题,我还没有找到完美的解决方案.我将以 meteor-router 为例:

As far as I can tell, the following options exist. Unfortunately, all of these have their own issues and I have yet to find the perfect solution. I will use meteor-router as an example:

步骤:

  • 删除packages/router/.git/
  • 编辑 packages/.gitignore 并删除 'router' 行
  • 从您的 smart.json
  • 中删除路由器
  • packages/router 添加到您的项目存储库并提交
  • 现在进行更改(这样您的初始提交是一个干净的版本,您可以自己计算出更改的内容)
  • remove packages/router/.git/
  • edit packages/.gitignore and remove the 'router' line
  • remove router from your smart.json
  • add packages/router to your project repository and commit
  • now make changes (this way your initial commit is a clean version and you can work out what you have changed yourself)

优点:

  • 易于实现和理解
  • 您依赖的所有代码都可以在您的项目存储库中找到

缺点:

  • 您丢失了所有原始存储库历史
  • 很难更新到新版本
  • 很难将您的更改贡献回原始项目

对于最简单的包,甚至不要考虑这个!

Do not even consider this for any but the simplest packages!

要在 github 上 fork 一个包,您可以检查您的 smart.lock 文件以查看正在使用哪个存储库.转到该存储库的 github 页面并对其进行分叉.

To fork a package on github, your can check your smart.lock file to see which repository is being used. Go to the github page of that repository and fork it.

接下来,您有三个选择:

Next, you have three options:

关于 git 子模块的更多信息:http://git-scm.com/book/en/Git-Tools-Submodules

More info on git submodules: http://git-scm.com/book/en/Git-Tools-Submodules

步骤:

  • 有关如何初始化/创建/更新子模块的信息,请参阅上面的链接
  • 从您的 smart.json
  • 中删除包

优点:

  • 子模块版本已连接到您的项目
  • 立即获取更改

缺点:

  • 所有开发者第一次都需要运行git submodule initupdate来更新
  • 编辑结帐时必须注意子模块的问题
  • 阅读子模块的其他问题

步骤:

  • 在你的 smart.json 中,找到 "router": {} 并添加 "git": "https://github.com/USER/meteor-router.git" 在空的 {} 中.
  • 可选地,添加 "branch""tag".
  • In your smart.json, find "router": {} and add "git": "https://github.com/USER/meteor-router.git" inside the empty {}.
  • Optionally, add a "branch" or "tag".

优点:

  • 您仍然可以使用 Meteorite 来管理您的外部包
  • 将自动为其他开发人员和部署环境工作

缺点:

  • 包文件夹中的代码不可编辑,因为它不是 git 存储库
  • Meteorite 不会在您每次运行时自动更新到最新版本

(建议 Meteorite 改进:允许以可编辑的形式安装包,如 Python 的 pip 允许使用-e"参数)

(Suggested Meteorite improvement: allow packages to be installed in an editable form, like Python's pip allows using the '-e' parameter)

步骤:

  • 将包克隆到项目之外的位置
  • 与 2b 类似,将 "path" 添加到您的 smart.json 以将 Meteorite 指向您的本地结帐
  • Clone the package to a place outside of your project
  • Similar to 2b, add a "path" to your smart.json to point Meteorite to your local checkout

优点:

  • 您可以随意编辑包,Meteor 会自动获取更改.

缺点:

  • 如果您提交此 smart.json,您很可能会破坏所有其他开发/部署环境...
  • If you commit this smart.json, you will most likely break all other development/deployment environments...

您使用哪种方法?您如何解决该方法的缺点?

Which method do you use? How do you work around the disadvantages to that method?

我可能遗漏了这些解决方案的一些问题.

I might have missed some issues with these solutions.

2b.编辑您项目的 smart.json 以使用您的版本

2b. Edit your project's smart.json to use your version

我会推荐这个版本,因为它最符合 smart.json 的使用和支持方式.我认为 mrt update 将正确反映 git repo 的最新信息.

I would recommend this version, as it is the most consistent with how the smart.json was intended to be used and supported. mrt update will correctly reflect the latest from the git repo I think.