从自定义 Gitlab 域安装时避免 .git 作曲家供应商中的文件夹
Avoiding .git folder in composer's vendor when installing from a custom Gitlab domain
我在 GitLab 管理的 git 存储库上有一个 Symfony 包。使用 composer 将包添加到 Symfony 并指向 gitlab 作为附加存储库。
一切正常,完美地跟踪依赖关系并且包确实按预期工作但是,为了优化我的项目源,我想避免在 [=25= 中包含 .git 文件夹]vendor/my-org/my-bundle 目录.
这里是 Symfony 项目 composer.json
的示例:
{
[...]
"require": {
[...]
"my-org/my-bundle": "dev-master"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"repositories": [
{
"type": "vcs",
"url": "https://mygitlab.mysite.com/author/my-bundle.git"
}
]
}
和捆绑的 composer.json :
{
"name": "my-org/my-bundle",
"type": "symfony-bundle",
"description": "blabla",
"keywords": ["symfony", "bundle"],
"license": "MIT",
"authors": [
{
"name": "ME Myself",
"role": "Developper"
}
],
"readme": "README.md",
"require": {
"php": ">=7.1.3",
"symfony/security-bundle": "4.4.*",
"symfony/config": "4.4.*",
"symfony/dependency-injection": "4.4.*",
"symfony/http-foundation": "4.4.*",
"symfony/http-kernel": "4.4.*",
"symfony/routing": "4.4.*",
"symfony/event-dispatcher": "4.4.*",
"symfony/property-access": "4.4.*",
"symfony/ldap": "4.4.*",
"psr/log": "^1|^2|^3"
},
"require-dev": {
"phpunit/phpunit": "^7"
},
"suggest": {
"symfony/phpunit-bridge": "^5.2"
},
"autoload": {
"psr-4": {
"Foo\Bar\": "src/Foo/Bar/"
}
}
}
补充信息:
- 我尝试将存储库类型设置为(在项目作曲家中为 gitlab/github) 但两者都缺少驱动程序;只有 git 有效。
- 我尝试了命令
composer install --prefer-dist
但没有成功(.git 仍然包括在内)。
- 作曲家版本:2.1.6
- 用户 UI 下载 zip/tar/... gitlab 的按钮提供了一个不包括 .git/.git 的存档忽略。
您的域未被识别为 GitLab 域,然后程序包被简单地从 Git 存储库中克隆出来。
您应该将域配置为 GitLab 域,以便 Composer 知道使用 Gtlab API。
除非您配置其他域,否则只有 gitlab.com
被视为 GitLab 域。
https://getcomposer.org/doc/06-config.md#gitlab-domains
据我所知,配置应该在 config.gitlab-domains
之内。像
{
"config": {
"gitlab-domains": [
"mygitlab.mysite.com"
]
}
}
我在 GitLab 管理的 git 存储库上有一个 Symfony 包。使用 composer 将包添加到 Symfony 并指向 gitlab 作为附加存储库。
一切正常,完美地跟踪依赖关系并且包确实按预期工作但是,为了优化我的项目源,我想避免在 [=25= 中包含 .git 文件夹]vendor/my-org/my-bundle 目录.
这里是 Symfony 项目 composer.json
的示例:
{
[...]
"require": {
[...]
"my-org/my-bundle": "dev-master"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"repositories": [
{
"type": "vcs",
"url": "https://mygitlab.mysite.com/author/my-bundle.git"
}
]
}
和捆绑的 composer.json :
{
"name": "my-org/my-bundle",
"type": "symfony-bundle",
"description": "blabla",
"keywords": ["symfony", "bundle"],
"license": "MIT",
"authors": [
{
"name": "ME Myself",
"role": "Developper"
}
],
"readme": "README.md",
"require": {
"php": ">=7.1.3",
"symfony/security-bundle": "4.4.*",
"symfony/config": "4.4.*",
"symfony/dependency-injection": "4.4.*",
"symfony/http-foundation": "4.4.*",
"symfony/http-kernel": "4.4.*",
"symfony/routing": "4.4.*",
"symfony/event-dispatcher": "4.4.*",
"symfony/property-access": "4.4.*",
"symfony/ldap": "4.4.*",
"psr/log": "^1|^2|^3"
},
"require-dev": {
"phpunit/phpunit": "^7"
},
"suggest": {
"symfony/phpunit-bridge": "^5.2"
},
"autoload": {
"psr-4": {
"Foo\Bar\": "src/Foo/Bar/"
}
}
}
补充信息:
- 我尝试将存储库类型设置为(在项目作曲家中为 gitlab/github) 但两者都缺少驱动程序;只有 git 有效。
- 我尝试了命令
composer install --prefer-dist
但没有成功(.git 仍然包括在内)。 - 作曲家版本:2.1.6
- 用户 UI 下载 zip/tar/... gitlab 的按钮提供了一个不包括 .git/.git 的存档忽略。
您的域未被识别为 GitLab 域,然后程序包被简单地从 Git 存储库中克隆出来。
您应该将域配置为 GitLab 域,以便 Composer 知道使用 Gtlab API。
除非您配置其他域,否则只有 gitlab.com
被视为 GitLab 域。
https://getcomposer.org/doc/06-config.md#gitlab-domains
据我所知,配置应该在 config.gitlab-domains
之内。像
{
"config": {
"gitlab-domains": [
"mygitlab.mysite.com"
]
}
}