使用 Mercurial 自动更新 `__version__`?

发布于 2024-12-04 19:18:43 字数 833 浏览 3 评论 0原文

可能的重复:
如何在 PHP 页面上显示 hg 存储库的当前工作副本版本

类似于 如何用 git 重写 python __version__ ?,它是什么在 python 文件中存储自动更新版本号的最佳方法?

我的有多好使用 Mercurial hooks 将版本号嵌入到我的应用程序中的方法?Mercurial 关键字计划 明确自动更新 $Revision$$Id$ 的 svn 风格方法是不可取的,并且构建系统应该做这项工作。但这是Python,没有构建系统,而且这是一个完全包含在一个文件中的小程序,因此没有打包。

Possible Duplicate:
How to display current working copy version of an hg repository on a PHP page

Similar to How can I rewrite python __version__ with git?, what it is the best method to store an automatically updated version number inside a python file?

How good is my method of embedding version numbers into my application using Mercurial hooks? and the Mercurial keyword plan make it clear the svn-style method of automatically updating $Revision$ or $Id$ is not desirable and that the build system should do that work instead. This is python though, there is no build system and this is for a small program wholly contained in one file, so there is no packaging.

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

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

发布评论

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

评论(1

左耳近心 2024-12-11 19:18:43

无论您使用哪种语言编写程序,您始终可以添加构建系统。您可能会说“但是语言 X 不需要构建系统”,但这个问题表明它确实需要:它需要它来完成那些重复性任务需要在任何发布之前完成。这些任务包括构建文档、运行测试以及将结果上传到某处。

一个简单的 Makefile 或 shell 脚本就足够了:

all: version

version:
    hg id > __version__

test: version
    @echo -n "running tests... "
    @sleep 1
    @echo " done."

doc: version
    @echo -n "building documentation... "
    @sleep 1
    @echo "done."

upload: test doc
    @echo -n "creating tarball... "
    @sleep 1
    @echo "done."
    @echo -n "publishing on website... "
    @sleep 1
    @echo "done."

.PHONY: version test upload doc

You can always add a build system, no matter which language you write your program in. You might say "but language X doesn't need a build system", but this question shows that it does: it needs it for those repetitive tasks that needs to be done before any release. This is tasks like building the documentation, running tests, and uploading the result somewhere.

A simple Makefile or a shell script is enough:

all: version

version:
    hg id > __version__

test: version
    @echo -n "running tests... "
    @sleep 1
    @echo " done."

doc: version
    @echo -n "building documentation... "
    @sleep 1
    @echo "done."

upload: test doc
    @echo -n "creating tarball... "
    @sleep 1
    @echo "done."
    @echo -n "publishing on website... "
    @sleep 1
    @echo "done."

.PHONY: version test upload doc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文