pip:如何安装Git的Pull Request

56
我想在本地虚拟环境中通过pip安装来自Github的git拉取请求以进行测试。我希望直接从github安装它,而无需创建本地git存储库。
2个回答

60

GitHub 提供了一个很棒的功能,它会预先合并 pull 请求,并将其作为一个隐藏的引用可供特别提取。如果您正在构建一个测试 pull 请求的 CI 系统,那么这是非常好的。

直到最近,pip 不支持指定这些隐藏引用,但在过去的一个月中,pip 已经支持了这一功能(在 10.0.1 中已确认可行)。

以下命令将安装用户/存储库下第123个 pull 请求的合并版本:

pip install git+https://github.com/user/repo.git@refs/pull/123/merge

此外,如果想要安装拉取请求123的未合并版本(而不必使用github API来跟踪原始分支!),请按照以下步骤操作:
pip install git+https://github.com/user/repo.git@refs/pull/123/head

5
pipenv 是否具备此功能? 编辑:可以实现,需在末尾提供 #egg=<package_name> 选项。 - jnowak
是的 - 这也是您需要做的,以便将其放入requirements.txt文件中进行pip install -r。 - Audrey Dutcher
这里的“refs”字面上是指“refs”这个单词吗? - Pro Q
是的,它是。refs是references的缩写,但你只需要输入“refs”。 - Audrey Dutcher

54

您可以通过在URL后附加哈希值来添加确切的提交记录:

pip install git+https://github.com/other-repository/project.git@remote_branch_name

例子:

pip install --user git+https://github.com/d1b/pip.git@fix_pip_build_directory

或者针对单个提交进行操作。但是,如果拉取请求(远程分支)得到更新,则此操作不会被更新:

pip install --user git+https://github.com/d1b/pip.git@d89b5803db2b520e754b9b26b771d22121738637

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接