如何在我的网站上获取文件的 Bazaar 版本?

发布于 2024-12-18 03:18:56 字数 280 浏览 5 评论 0原文

我之前也遇到过类似的问题。一个例子: 如何获取 svn 修订号在 PHP 中?

但今天我正在处理一个使用 BZR 管理的项目。我需要获取特定文件的集市版本,并在我们的网站上发布该图,以便在文件更新时自动更新。

该网站全部使用 Python 编写,因此我愿意在幕后读取文件,但如果有的话,我更喜欢更被动的方法。

There have been similar questions to this that I've been involved with before. One example: How can I get the svn revision number in PHP?

But today I'm tackling a project that is managed with BZR. I need to get the bazaar version for a particular file and publish that figure on our website in a way that it automatically updates when the file is update.

The website is all in Python so I'm open to reading files behind the scenes but I would prefer a more passive method if available.

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

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

发布评论

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

评论(3

紫﹏色ふ单纯 2024-12-25 03:18:56

如果您需要获取修改文件的最新版本,可以使用以下命令:

bzr log -l1 --line <file> | cut -f1 -d:

If you need to get the latest revision in which a file was modified, you can doit using the following command:

bzr log -l1 --line <file> | cut -f1 -d:
软糖 2024-12-25 03:18:56

在Python中:

from bzrlib.branch import Branch
b = Branch.open(location_of_your_branch)
b.lock_read()
try:
    # Retrieve the contents of the last revision
    t = b.basis_tree()
    revid = t.get_file_revision(t.path2id(your_filename))
    print ".".join([str(x) for x in b.revision_id_to_dotted_revno(revid)])
finally:
    b.unlock()

In Python:

from bzrlib.branch import Branch
b = Branch.open(location_of_your_branch)
b.lock_read()
try:
    # Retrieve the contents of the last revision
    t = b.basis_tree()
    revid = t.get_file_revision(t.path2id(your_filename))
    print ".".join([str(x) for x in b.revision_id_to_dotted_revno(revid)])
finally:
    b.unlock()
带刺的爱情 2024-12-25 03:18:56

一种方法是使用一个脚本推送到您的网站,此脚本案例更新 version.py 或类似的内容:

# update version
echo "VERSION = \"$(bzr revno)\"" > version.py
# push to website
rsync ...
# tag
bzr tag --force deployed-version

One way is to have a script that pushes to your website, this script case update version.py or something like that:

# update version
echo "VERSION = \"$(bzr revno)\"" > version.py
# push to website
rsync ...
# tag
bzr tag --force deployed-version
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文