如何在Composer和私有git仓库中使用特定标签/版本? [英] How to use a specific tag/version with composer and a private git repository?
问题描述
我公司的Gitlab上有一些软件包托管。我想请求这些软件包的特定版本,但是每次尝试时,作曲家都下载master分支的最新提交。
composer.json:
{
name : MyProject,
需要 :{
用户/项目 : v0.5.0&;
},
type : project,
repositories; :[[
{
" url" : git@gitlab.XXXX.fr:user / project.git,
类型 : vcs;
}
],
config :{
vendor-dir; :私人/阶级;
}
}
我的软件包存储库的结构:
- 标记v0.5.0:commit dd6ed3c8 ...
- commit X,Y,Z
- 标签v0.7.0:提交15293ac6 ...
- 最后一次提交f15600a1 ...
当我执行 ; composer install :
使用包信息加载作曲家存储库
安装依赖项(包括require-dev)
分析了69个软件包来解决依赖关系
分析了67条规则来解决依赖关系
安装用户/项目(dev-master f15600a)
克隆f15600a1
它仅下载最后一次提交。
如何配置项目的composer.json文件以使用特定标签?
如何要求特定的Git标签?
更改版本要求为 dev-master
,后跟一个哈希#
和Git标签名称,例如 v0.5.0
,如下所示:
require:{
供应商/包装: dev-master#v0.5.0
}
如何要求特定的Git提交?
将版本要求更改为 dev-master
,后跟一个哈希#
和Git提交引用,例如 dd6ed3c8
,就像这样:
要求:{
供应商/包装: dev-master#dd6ed3c8
}
https://getcomposer.org/doc/04-schema.md#package-links
定义您自己的软件包并设置版本和参考
处理 type类型的存储库: vcs
的另一种方法是定义自定义包存储库中的 type: package
并使用引用。
引用可以是Git提交哈希,也可以是标记或分支名称,例如 origin / master
。 / p>
这会将版本
与特定的提交引用
关联,在这种情况下为dd6ed3c8。
存储库:[
#...
{
type: package,
package:{
name:供应商/包装,
version: v0.5.0,
源:{
url: git@gitlab.server.com:vendor / project.git,
type: git,
reference: dd6ed3c8
}
}
}
]
I've got some packages host on the Gitlab of my company. I want to request a specific version of these packages but each time I try, composer download the latest commit of the master branch.
composer.json :
{
"name" : "MyProject",
"require" : {
"user/project" : "v0.5.0"
},
"type" : "project",
"repositories" : [
{
"url" : "git@gitlab.XXXX.fr:user/project.git",
"type" : "vcs"
}
],
"config" : {
"vendor-dir" : "private/class"
}
}
The structure of the repository of my package :
- tag v0.5.0 : commit dd6ed3c8...
- commit X,Y,Z
- tag v0.7.0 : commit 15293ac6...
- last commit f15600a1...
When I execute "composer install" :
Loading composer repositories with package information
Installing dependencies (including require-dev)
Analyzed 69 packages to resolve dependencies
Analyzed 67 rules to resolve dependencies
Installing user/project (dev-master f15600a)
Cloning f15600a1
It downloads the last commit only.
How can I configure the composer.json file of my project to use a specific tag ?
How to require a specific Git tag?
Change the version requirement to dev-master
, followed by a hash #
and the Git tag name, e.g. v0.5.0
, like so:
"require": {
"vendor/package": "dev-master#v0.5.0"
}
How to require a specific Git commit?
Change the version requirement to dev-master
, followed by a hash #
and the Git commit reference, e.g. dd6ed3c8
, like so:
"require": {
"vendor/package": "dev-master#dd6ed3c8"
}
Referencing: https://getcomposer.org/doc/04-schema.md#package-links
Define your own package and set version and reference
An alternative to working with repositories of "type": "vcs"
is to define a custom package "type": "package"
inside repositories and work with a reference.
The reference is either a Git commit hash, or a tag or branch name, like origin/master
.
This will tie the version
to a specific commit reference
, in this case dd6ed3c8.
"repositories": [
# ...
{
"type": "package",
"package": {
"name": "vendor/package",
"version": "v0.5.0",
"source": {
"url": "git@gitlab.server.com:vendor/project.git",
"type": "git",
"reference": "dd6ed3c8"
}
}
}
]
这篇关于如何在Composer和私有git仓库中使用特定标签/版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!