开发者

What is the best way to include Mercurial changeset id (or revision) in a Django template?

开发者 https://www.devze.com 2023-02-14 12:56 出处:网络
I am developing a Django site and am using hg for revision control. I would like to embed the changeset id to the footer of the site like Stackoverflow and Bitbucket do in their footer. What is the be

I am developing a Django site and am using hg for revision control. I would like to embed the changeset id to the footer of the site like Stackoverflow and Bitbucket do in their footer. What is the best way to accomplish this?

Do I have to use the Mercurial api? Is there a way to get hg form the CLI to output just the revision id so I 开发者_如何学JAVAcan capture that in my deployment scripts and just include the simple text output in the template?

Methods you have used would be appreciated. Thanks


See: KeywordPlan

In your release-to-production process, use hg id to get the current version information from Mercurial. You can easily stash that in a file that you then include in your Django templates.

For example, in whatever script/process you use at release time, do:

hg id >templates/id.html

And then at the bottom in your main Django template (or wherever), add:

Revision:  {{ include "templates/id.html" }}

(NOTE: the paths/directories may vary depending on how you have your template paths configured in Django).

0

精彩评论

暂无评论...
验证码 换一张
取 消