php - Composer : scan only tag names, 不是整个 composer.json

标签 php git composer-php

我主要使用 composer 来管理 git 存储库(本地和远程)。 Composer 读取所有历史提交中的每个标记的 composer.json 实例:

Reading composer.json of tomekwi/composer-installers (v1.0.0)
Importing tag v1.0.0 (1.0.0.0)
Reading composer.json of tomekwi/composer-installers (v1.0.1)
Importing tag v1.0.1 (1.0.1.0)
Reading composer.json of tomekwi/composer-installers (v1.0.2)
Importing tag v1.0.2 (1.0.2.0)
Reading composer.json of tomekwi/composer-installers (v1.0.3)
Importing tag v1.0.3 (1.0.3.0)
Reading composer.json of tomekwi/composer-installers (v1.0.4)
Importing tag v1.0.4 (1.0.4.0)
Reading composer.json of tomekwi/composer-installers (v1.0.5)
Importing tag v1.0.5 (1.0.5.0)
Reading composer.json of tomekwi/composer-installers (v1.0.6)
Importing tag v1.0.6 (1.0.6.0)
Reading composer.json of tomekwi/composer-installers (1.x)
Importing branch 1.x (1.x-dev)

...etc

较大的存储库需要很长时间。另外,它会导致 github ( https://circleci.com/docs/composer-api-rate-limit) 出现问题

如果我理解正确的话,这样做的目的是从每个 composer.json 文件中提取版本号。如果 Composer 仅通过读取标签名称来选择正确的版本,那将会快得多。请求 "tomekwi/composer-installers": "~1.0" 可能如下所示:

Reading tags of tomekwi/composer-installers
  - Picked matching tag (v1.0.6)
Reading composer.json of tomekwi/composer-installers (v1.0.6)
  - Installing tomekwi/composer-installers (v1.0.6)

..花半秒而不是半分钟。

有可能吗?

最佳答案

Composer 不知道存储库中有什么包。所以它必须读取 composer.json 才能找出答案。

并且因为软件可以重命名,所以不能保证在存储库中找到的每个标签都属于同一个包名。

您应该看看托管 Packagist 或 Satis 的本地实例。这些工具会扫描您的存储库并获取 Composer 工作所需的信息。 Satis 也可能将找到的标签转储到 ZIP 文件中,这也加快了安装过程(从本地服务器解压缩下载的文件通常比克隆 repo 更快)。

关于php - Composer : scan only tag names, 不是整个 composer.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19010927/

相关文章:

php - MySQL 仅当该记录的日期时间列数据发生更改时才更新该数据

git - 在 git svn fetch 期间解包树对象时出现 fatal error

php - 如何以编程方式获取已安装的 Composer 包?

git - 无法 fork DevOps git repo-服务不受支持

composer-php - 'composer'不被识别为内部或外部命令

composer-php - composer 不会从 composer.lock 中删除条目

php - fatal error : Call to a member function bind_param() for login page

javascript - 发布到网址时,Google Analytics 事件不会触发

php - 如何使用 Doctrine2 中的查询生成器更新多个字段?

GIT:无法暂存更改以提交,在我提交更改之前无法 pull