简体   繁体   English

Composer 使用仓库的私有分支

[英]Composer use private fork of a repository

This question is clearly answered in other places, but it simply does not work for me.这个问题在其他地方得到了明确的回答,但对我来说根本不起作用。 I can also see a lot of people have problems with this.我也可以看到很多人对此有疑问。

I am trying to use a fork of CCXT (branch name is bitmart ) in my own project as it contains some major changes which have not yet been merged with the original ccxt/ccxt我正在尝试在我自己的项目中使用 CCXT 的分支(分支名称是bitmart ),因为它包含一些尚未与原始ccxt/ccxt合并的重大更改

git version: 2.20.1 git 版本:2.20.1
composer version 1.7.2作曲家版本 1.7.2

My composer file in my project looks like this:我的项目中的 Composer 文件如下所示:

"repositories": [{
    "type": "vcs",
    "url": "git@github.com:devsi/ccxt"
}],
 "require": {
    "ccxt/ccxt": "dev-bitmart as 1.18.409"
}

I've tried the https url : https://github.com/devsi/ccxt and it still does not work.我已经尝试了 https url:https: https://github.com/devsi/ccxt ,但它仍然不起作用。

I have tried removing the version constraint and instead it tries to read every single version release ever in CCXT.我尝试删除版本约束,而是尝试读取 CCXT 中的每个版本。 The processing time would take hours.处理时间将需要数小时。 It does about 1 per second.它大约每秒执行 1 次。

Reading composer.json of ccxt/ccxt (1.17.378)
Reading composer.json of ccxt/ccxt (1.17.377)
Reading composer.json of ccxt/ccxt (1.17.376)

and so on.等等。

When specifying a version, the error I receive is:指定版本时,我收到的错误是:

Failed to clone the git@github.com:devsi/ccxt.git repository, 
try running in interactive mode so that you can enter your GitHub credentials


  [RuntimeException]                                                                                                               
  Failed to execute git clone --mirror 'git@github.com:devsi/ccxt.git' '/root/.composer/cache/vcs/git-github.com-devsi-ccxt.git/'   

What am I doing wrong?我究竟做错了什么?

So for anyone else who finds this problem.所以对于任何发现这个问题的人。 My fork of the repository was up to date with the latest version of the original source.我的存储库分支是最新版本的原始源。 However, the tags were not.然而,标签不是。 As git fetch does not fetch the tags, when synchronizing your fork and the source, make sure you also git fetch upstream --tags and git push --tags to bring the releases up to date too.由于 git fetch 不获取标签,因此在同步您的 fork 和源时,请确保您也git fetch upstream --tagsgit push --tags以使发布也保持最新。 Without this I was given an obscure warning about credentials and failing to execute git clone.如果没有这个,我会收到一个关于凭据和无法执行 git clone 的模糊警告。 The real error was:真正的错误是:

[InvalidArgumentException]                                                                                                                                            
  Could not find a version of package devsi/ccxt matching your minimum-stability (dev)

This also explains why it was reading every version one by one.这也解释了为什么它要一个一个地阅读每个版本。 It could never find the version it needed as it wasn't available in the forked repo.它永远找不到它需要的版本,因为它在分叉仓库中不可用。

Once the tags were up to date.一旦标签是最新的。 the VCS method worked. VCS 方法有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM