提交或推送到 kiln 时自动标记变更集

发布于 2024-10-05 21:58:27 字数 214 浏览 10 评论 0原文

我想知道是否有一种方法可以在本地提交或推送到 kiln 存储库时自动标记变更集。

我希望每个变更集都有一个带有版本/内部版本号的标签。我计划将我的版本/内部版本号存储在数据库中,并希望有一个脚本从数据库中检索该值并将标签添加到变更集中。是否可以自动调用脚本来将其作为提交后事件或推送到 kiln 存储库时的推送后事件来执行?

我也愿意接受任何其他方法来实现每次提交/推送的自动标记。

I would like to know if there is a way to automatically tag a changeset as it is committed locally or when pushed to the kiln repository.

I would like every changeset to have a tag with version/build number. I am planning to store my version/build numbers in a database and would like to have a script retrieve this value from the database and add a tag to the changeset. Is it possible to invoke a script automatically to do this as a post-commit event or as a post-push event when pushed to the kiln repository?

I am also open to any other approaches to achieve automatic tagging on every commit/push.

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

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

发布评论

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

评论(2

离笑几人歌 2024-10-12 21:58:27

与其为每个变更集创建标签,为什么不尝试以下方法之一:

  • 使用变更集哈希作为标识符?
  • 使用从日志生成的字符串作为标识符(见下文)?

可以使用以下命令从日志中生成描述性字符串:

hg log -r 1.7.2 --template '{latesttag}-{latesttagdistance}-{node}\n'

结果采用以下形式:

<latest tag>-<# changesets since latest tag>-<changeset hash>

例如,在 Mercurial 存储库的本地克隆上,会生成:

1.7.2-2-5e51254ad4d4c80669f462e310b2677f2b3c54a7

这告诉我自标签 1.7.2 以来已经有两次提交,并且当前变更集哈希是 5e51254a。

在 Mercurial 中,每个标签都会创建一个新的变更集。因此,如果您为每个提交添加标签,那么存储库中的变更集数量就会增加一倍。您应该使用内置工具(如上所述)而不是尝试重新创建轮子。

Rather than creating a tag for each changeset, why not try one of the following:

  • Use the changeset hash as your identifier?
  • Use a string generated from the log as your identifier (see below)?

A descriptive string can be generated from the log using this command:

hg log -r 1.7.2 --template '{latesttag}-{latesttagdistance}-{node}\n'

The result takes the form:

<latest tag>-<# changesets since latest tag>-<changeset hash>

For example, on my local clone of the Mercurial repo, this generates:

1.7.2-2-5e51254ad4d4c80669f462e310b2677f2b3c54a7

Which tells me that there have been two commits since tag 1.7.2 and the current changeset hash is 5e51254a.

In Mercurial, each tag creates a new changeset. So if you tag every commit, you double the number of changesets in the repo. You should use the built-in tools (as described above) rather than try to recreate the wheel.

弥枳 2024-10-12 21:58:27

我想知道是否有一种方法可以在本地提交或推送到 kiln 存储库时自动标记变更集。

您始终可以编写一个提交后挂钩来执行此操作。

我希望每个变更集都有一个带有版本/内部版本号的标签。

标签对于识别提交历史记录中的重要时刻很有用。为这些时刻提供一个与产品开发相关的有意义的名称,例如版本 1.0、版本 1.3 等。

如果您要为每个更改集制作一个标签,那么您只会增加噪音水平。您仍然需要在某个地方保留有关重要标签的信息。

将标签视为有关变更集的元信息。并非所有这些都值得同等重视。并非所有这些都需要元信息。

只有当您谨慎使用标签时,查看标签才能为您提供有意义的历史记录。

挂在钩子上

请参阅:

示例:通过推送、拉取添加变更组后运行或解绑。我用它来触发自动构建。

[hooks]
changegroup.yyyy = command 

同样,还有 post-commit 、 post-push hooks

[hooks]
post-<command> =  command

I would like to know if there is a way to automatically tag a changeset as it is committed locally or when pushed to the kiln repository.

You could always write a post commit hook to do that.

I would like every changeset to have a tag with version/build number.

Tags are useful to identify important moments in your commit history. Providing those moments a meaningful name that relates to the product development like release 1.0, release 1.3 etc .

If you were to make a tag every change set then you would just increase noise level. You will still need to keep information about important tags some where.

Consider tag as meta information about change-sets. Not all of them deserve the same importance. Not all of them require that meta information.

Looking at tags can give you meaningful history only when you use them sparingly.

On hooks

See:

Example: Run after a changegroup has been added via push, pull or unbundle. I have used it to trigger automatic builds.

[hooks]
changegroup.yyyy = command 

Similarly, there is post-commit , post-push hooks

[hooks]
post-<command> =  command
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文