你会如何将当前的提交ID包含在Git项目的文件中? [英] How would you include the current commit id in a Git project's files?

查看:122
本文介绍了你会如何将当前的提交ID包含在Git项目的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个开源的静态JavaScript + HTML应用程序,它现在被部署在三个不同的地方,一个在本地机器上,一个在内部服务器上,另一个在稳定的外部服务器上。 b
$ b

我希望能够立即知道在哪个地方部署了哪个版本,并且我希望bug记者轻松访问他们报告错误的版本。

理想情况下,作为提交过程的一部分,我希望使用提交的散列编写文件。当然,从我所知道的Git中,这是不可能的,因为在计算散列作为提交文件的一部分时会改变计算的提交散列。

另一方面,我可以将它作为构建过程的一部分来构建。我目前还没有构建过程,如果可能的话,我想避免添加一个步骤。



最干净的方法是什么?

解决方案

将它添加到您的自动部署系统中。 自动化,然后自动化并将其添加到那里。然后你删除了一个步骤。



使它更有用这是在x日期时间从z存储库部署的。对于非开发人员来说,提交的散列并不是真正的意义。


I've got an open source static JavaScript + HTML application that's deployed in about three different places right now, one on my local machine, one on an internal server, and one on a stable external server.

I'd like to be able to tell immediately which version is deployed in which place, and I'd like bug reporters to have easy access to the version that they're reporting the bug on.

Ideally I'd like, as part of the commit process, for a file to be written with the hash of the commit. Of course, from what I know of Git this is impossible, as including the calculated hash as part of a file in a commit would change the calculated hash of that commit.

On the other hand, I could incorporate building this as part of a build process. I don't currently have a build process though, and I'd like to avoid adding a step if possible.

What's the cleanest way to do this?

解决方案

Add it to your automated deploy system.

If your deploy isn't automated, then automate it and add it there. Then you have removed a step.

Make it a more useful "this was deployed on x date at y time from z repository". The hash of the commit doesn't really mean a whole lot to non-developers.

这篇关于你会如何将当前的提交ID包含在Git项目的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆