git 如何使用 Composer 将代码标记为稳定?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11650543/
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-09-19 07:16:16  来源:igfitidea点击:

How to mark code as stable using Composer?

phpgitcomposer-php

提问by Adam

I've recently come across the change in composer meaning that the default minimum-stabilityis stable, and rather than set this to devI'd like to mark some of my libraries as stable.

我最近遇到了 composer 的变化,这意味着默认minimum-stabilitystable,而不是将其设置为dev我想将我的一些库标记为稳定的。

I actually use two relevant branches, releaseand devbranched from master. Every so often something is merged into releaseand tagged as new version.

我实际上使用了两个相关的分支,releasedevmaster. 每隔一段时间,某些内容就会合并release并标记为新版本。

How does composer determine the stability of my libraries, is there a naming convention for branches, version nums, a key in composer.json?

composer 如何确定我的库的稳定性,是否有分支、版本号、composer.json 中的键的命名约定?

Thanks

谢谢

采纳答案by KingCrunch

The answer is: Tags. Your may also use Alias, if you don't want to use tags. But it's worth to mention, that you should only mark your packages as stable, when they are stable and not to make others believe they are.

答案是:标签。如果您不想使用标签,您也可以使用Alias。但值得一提的是,您应该只将您的软件包标记为稳定的,当它们稳定时,而不是让其他人相信它们是稳定的。

Update: One more link: Stability

更新:还有一个链接:稳定性

回答by iautomation

Elaborating on KingCrunch's answer, since this was not immediately obvious to me.

详细说明 KingCrunch 的回答,因为这对我来说并不是很明显。

From https://getcomposer.org/doc/02-libraries.md#specifying-the-version

来自https://getcomposer.org/doc/02-libraries.md#specifying-the-version

When you publish your package on Packagist, it is able to infer the version from the VCS (git, svn, hg) information. This means you don't have to explicitly declare it.

当您在 Packagist 上发布您的包时,它能够从 VCS(git、svn、hg)信息推断版本。这意味着您不必明确声明它。

This is very easy with Github: https://help.github.com/articles/working-with-tags/

使用 Github 这很容易:https: //help.github.com/articles/working-with-tags/

Furthermore:

此外:

If you are creating packages by hand and really have to specify it explicitly, you can just add a version field:

{
    "version": "1.0.0" 
}

如果您手动创建包并且确实必须明确指定它,则只需添加一个版本字段:

{
    "version": "1.0.0" 
}

回答by Maxime Culea

To answer the question :

回答这个问题:

  • for VCS, it's dev-master
  • for packagist, it's *@stable
  • 对于 VCS,它是 dev-master
  • 对于包装师来说,它是 *@stable


For more about "stabilizing" or "freezing" composer versions

有关“稳定”或“冻结”作曲家版本的更多信息

Freeze Make Stable

冻结使稳定

It's sometimes useful, especially during an audit, to grab latest versions of your requirements, that's why we made a composer package make stable all your dependencies : Composer Make Stable(https://github.com/BeAPI/composer-make-stable).

有时,特别是在审计期间,获取您的需求的最新版本很有用,这就是为什么我们制作了一个 composer 包使您的所有依赖项保持稳定:Composer Make Stable( https://github.com/BeAPI/composer-make-stable) .

Using this command, your dependencies into composer.json will be automatically be changed from:

使用此命令,您对 composer.json 的依赖项将自动更改为:

"wpackagist-plugin/wordpress-seo":"6.2"

"wpackagist-plugin/wordpress-seo":"6.2"

into:

进入:

"wpackagist-plugin/wordpress-seo":"*@stable"

"wpackagist-plugin/wordpress-seo":"*@stable"

Freeze Composer Versions

冻结作曲家版本

If afterwards you plan doing the reverse thing to grab latest versions of your composer.lock which you tested your site against, especially useful while making a site live, have a look to an other of our composer command : Composer Freeze Version(https://github.com/BeAPI/composer-freeze-version).

如果之后您打算做相反的事情来获取您测试站点的最新版本的 composer.lock,在使站点上线时特别有用,请查看我们的另一个 composer 命令:Composer Freeze Version( https:/ /github.com/BeAPI/composer-freeze-version)。

Using this command, your dependencies into composer.json will be automatically be changed from:

使用此命令,您对 composer.json 的依赖项将自动更改为:

"wpackagist-plugin/wordpress-seo":"@stable"

"wpackagist-plugin/wordpress-seo":"@stable"

into:

进入:

"wpackagist-plugin/wordpress-seo":"6.2"

"wpackagist-plugin/wordpress-seo":"6.2"



Hope it helps.

希望能帮助到你。