php 如何让 Composer 从 GitHub 下载 master 分支中的最新提交以获取包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19916183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:13:56  来源:igfitidea点击:

How do I get Composer to download the latest commit in the master branch from GitHub for a package?

phpgitgithubcomposer-php

提问by Patrick

I am trying to get Composer do download the latest commit for the Behat/MinkSelenium2Driver package. That particular repo only has a master branch. I have tried every method I can think of, including deleting the files and letting it pull them back in, to get it to work but it doesn't.

我试图让 Composer 下载 Behat/MinkSelenium2Driver 包的最新提交。那个特定的 repo 只有一个 master 分支。我已经尝试了我能想到的所有方法,包括删除文件并让它将它们拉回来,以使其工作,但它没有。

How would I get it to pull in latest committed files or at least those from the commit I list below?

我如何让它拉入最新提交的文件或至少是我在下面列出的提交中的文件?

Specifically I want to get this commit: https://github.com/Behat/MinkSelenium2Driver/commit/2e73d8134ec8526b6e742f05c146fec2d5e1b8d6

具体我想得到这个提交:https: //github.com/Behat/MinkSelenium2Driver/commit/2e73d8134ec8526b6e742f05c146fec2d5e1b8d6

Thanks, Patrick

谢谢,帕特里克

回答by Sven

There is only one way to grab the head of the repository:

只有一种方法可以获取存储库的头部:

"require": { "behat/mink-selenium2-driver" : "dev-master" }
"minimum-stability": "dev"

Oh well, at least two ways:

哦,至少有两种方式:

"require": { "behat/mink-selenium2-driver" : "dev-master as 1.1.x-dev" }
"minimum-stability": "dev"

Probably at least three ways:

大概至少三种方式:

"require": { "behat/mink-selenium2-driver" : "dev-master#2e73d8134ec8526b6e742f05c146fec2d5e1b8d6" }
"minimum-stability": "dev"

Because that repository actually aliased the master branch as 1.1.x-dev, this would also work without the minimum-stability affecting all other packages:

因为该存储库实际上将 master 分支别名为 1.1.x-dev,所以这也可以在不影响所有其他包的最小稳定性的情况下工作:

"require": { "behat/mink-selenium2-driver" : "1.1.*@dev" }

回答by Berend de Boer

Simply specify the master branch:

只需指定主分支:

composer require --dev behat/mink-selenium2-driver:dev-master

PS: the --dev is just to specify it's a test/development requirement, that's probably what you want.

PS: --dev 只是指定它是测试/开发要求,这可能是您想要的。

回答by lmsurprenant

In our case, none of the previous answers were working. It turned out to be something simple:

在我们的例子中,之前的答案都没有奏效。结果很简单:

Composer only uses the repositories attribute of the ROOT composer.json

Composer 只使用 ROOT composer.json 的 repositories 属性

https://getcomposer.org/doc/04-schema.md#repositories

https://getcomposer.org/doc/04-schema.md#repositories

In our case, we were trying to get the latest commit from dev-master of one of our transitive dependencies. There was some problem with the hooks between github and packagist preventing it from working like normal and it took us a couple hours to realize that we were editing the wrong composer.json (the one from our library that carries the dependency) instead of the top-level composer.json that we were installing.

在我们的例子中,我们试图从我们的一个传递依赖项的 dev-master 获取最新提交。github 和 packagist 之间的挂钩存在一些问题,导致它无法正常工作,我们花了几个小时才意识到我们正在编辑错误的 composer.json(来自我们库中的带有依赖项的)而不是顶部我们正在安装的 -level composer.json。

回答by Jules Shoemaker

To download the latest version of a repo, I usually use:

要下载最新版本的 repo,我通常使用:

composer update behat/mink-selenium2-driver

This will update your composer.lock with the last available commit reference.

这将使用最后一个可用的提交参考更新您的 composer.lock。