Homebrew:如何使用pull请求中的公式

时间:2011-08-31 10:54:52

标签: git github-api

我是GIT和GitHub的新手(和Homebrew一样);主存储库中emacs的公式在OS X Lion中被破坏了,但有一个“拉取请求”(https://github.com/mxcl/homebrew/pull/6518)可以修复问题(但它不是合并在主存储库中。)

如何更新Homebrew存储库的本地副本以修复该公式?如果我管理它,如果主存储库包含该修复程序,该公式是否仍会更新?

如果术语不正确,请纠正我。

3 个答案:

答案 0 :(得分:54)

您可以使用brew install $raw_pull_requst_url直接从拉取请求安装自制软件公式,例如:

brew install https://raw.github.com/ColinHebert/homebrew/538a99cc06a8f40b6ebcf2f4f8fd44d563c672cd/Library/Formula/emacs.rb

要查找拉取请求网址,可能有更好的方法,但我转到您链接的拉取请求网址,点击文件已更改,然后点击查看文件@ 9b22d42 ,最后是 Raw

答案 1 :(得分:15)

Github上的文档描述了相当详细(合并提取请求部分):

你的回购邮件上的

git checkout master
git remote add colin https://github.com/ColinHebert/homebrew.git
git fetch colin

现在,您拥有colin repo的完整内容(包括该repo中使用的提交哈希的知识)。接下来是应用更改。文档说你应该做git merge,但在我们的案例中这并不是很好,因为科林将更改添加到他的master。如果他在master上工作(并做更多提交),你也会得到这些改变。

幸运的是,组成补丁的四个提交在Pull-request中命名:ae28b29edf10b69ae891548887f2d1e5。您可以使用git cherry-pick

来应用它们
git cherry-pick ae28b29e
git cherry-pick df10b69a
git cherry-pick e8915488
git cherry-pick 87f2d1e5

就是这样。您现在可以使用

删除远程colin
git remote rm colin

另一种可能性是下载补丁并应用它:

git checkout master
curl https://github.com/mxcl/homebrew/pull/6518.patch | git am

拉取请求的补丁始终可以通过

获得
https://github.com/<user>/<repo>/pull/<request_number>.patch

答案 2 :(得分:10)

我发现以下对于休闲自制软件用户来说更好。

如果您正在搜索修复程序,则会有一个拉号:

| => brew search vmdktool
No formula found for "vmdktool".
==> Searching pull requests...
Open pull requests:
vmdktool 1.4 (new formula) (https://github.com/Homebrew/homebrew-core/pull/9109)

只需brew pull ####,其中####是拉号:

| => brew pull 9109
fatal: ref HEAD is not a symbolic ref
Warning: Current branch is : do you need to pull inside master?
==> Fetching patch
Patch: https://github.com/Homebrew/homebrew-core/pull/9109.patch
==> Applying patch
Applying: vmdktool 1.4 (new formula)
==> Patch closes issue #9109
==> Patch changed:
 Formula/vmdktool.rb | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

然后进行安装/升级:

| => brew install vmdktool
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from 11cf7b9 to 1f97e31.
No changes to formulae.

==> Using the sandbox
==> Downloading https://people.freebsd.org/~brian/vmdktool/vmdktool-1.4.tar.gz
######################################################################## 100.0%
==> make CFLAGS='-D_GNU_SOURCE -g -O -pipe'
==> make install PREFIX=/usr/local/Cellar/vmdktool/1.4
  /usr/local/Cellar/vmdktool/1.4: 4 files, 34.4K, built in 2 seconds