如何使git描述使用SEMVER兼容标签

发布于 2025-01-27 01:37:54 字数 539 浏览 3 评论 0原文

我希望我的git Dricesd Dricesd Invocation仅使用REFS 符合语义版本。 为了保持简单,目前,我不在乎其他选择 (就像仅注释的标签一样,分支,候选人,...)。

示例:

我已经标记了1.1.1(semver兼容)的早期/旧提交, 最近使用my-Software-2.2.2的提交 以及Some-random-tag的更新一个。 我希望我的git Dricesd调用仅考虑1.1.1标签。

这里的主要困难, 似乎是按照其名称限制标签的方法基于 globs , 不发条。

I want my git describe invocation to use only refs
that conform to semantic versioning.
To keep it simple, for now, I do not care about other options
(like annotated tags only, branches, candidates, ...).

Example:

I have tagged an early/old commit with 1.1.1 (semver compatible),
a more recent commit with my-software-2.2.2,
and an even newer one with some-random-tag.
I want my git describe invocation to only consider the 1.1.1 tag.

The main difficulty here,
seems to be that the way to limit the tags by their name is based on globs,
not regex.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请持续率性 2025-02-03 01:37:54

我到目前为止找到的最佳选项:

git describe \
    --match='[0-9]*.[0-9]*.[0-9]*' \
    --exclude='*[^0-9.]*'

因为- 匹配标志仅支持原始地球,
不完整的正则
此检查仅考虑表单integer.integer.integer.integer的非常简单的semver。
忽略其他有效的有效,例如:

  • 2.0.0-rc.2
  • 2.0.0-rc.1
  • 1.0.0.0-beta
  • 1.0.0-alpha+001
  • 1.0.0+20130313144700
  • 1.0.0-beta+exp.sha.5114f85
  • 1.0.0.0+21af26d3- -117B344092BD

The best option I found so far:

git describe \
    --match='[0-9]*.[0-9]*.[0-9]*' \
    --exclude='*[^0-9.]*'

Because the --match flag only supports primitive globs,
not full regex,
this check only considers very simple semver's of the form integer.integer.integer,
disregarding other valid ones, like:

  • 2.0.0-rc.2
  • 2.0.0-rc.1
  • 1.0.0-beta
  • 1.0.0-alpha+001
  • 1.0.0+20130313144700
  • 1.0.0-beta+exp.sha.5114f85
  • 1.0.0+21AF26D3—-117B344092BD
小苏打饼 2025-02-03 01:37:54

另一个选择是使用(核心GIT独立)GO工具:
git-descripe-semver

示例用法:

cd my-git-directory
docker pull ghcr.io/choffmeister/git-describe-semver:latest
docker run --rm -v $PWD:/workdir ghcr.io/choffmeister/git-describe-semver:latest

An other option is to use the (core git independent) Go tool:
git-describe-semver.

sample usage:

cd my-git-directory
docker pull ghcr.io/choffmeister/git-describe-semver:latest
docker run --rm -v $PWD:/workdir ghcr.io/choffmeister/git-describe-semver:latest
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文