git是否有像`svn propset svn:keywords`或pre / post-commit hooks之类的东西? [英] Does git have anything like `svn propset svn:keywords` or pre-/post-commit hooks?

查看:110
本文介绍了git是否有像`svn propset svn:keywords`或pre / post-commit hooks之类的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过浏览git文档,我看不到任何类似于SVN的提交钩子或propset特性的东西,例如,只要将文件提交到存储库,就可以更新文件中的版本号或版权声明。 / p>

git用户是否希望为这种功能编写外部脚本(这看起来没有问题)或者我错过了一些明显的东西?



编辑:要清楚,我更感兴趣,例如,

  svn propset svn:keywords作者日期ID​​修订expl3.dtx 

这里有一个字符串:

  $ Id:expl3.dtx 780 2008-08-30 12:32:34Z morten $ 

在发生提交时与相关信息保持同步。

解决方案




git是否有关键字扩展?



不推荐。关键字扩展会导致各种各样的奇怪问题,无论如何,
并不是真正有用的,特别是在SCM的上下文中。在
之外,您可以使用脚本执行关键字扩展。 Linux内核导出
脚本可以设置Makefile中的EXTRA_VERSION变量。



如果您真的想这样做,请参阅gitattributes(5)。如果您的翻译不是
可逆的(例如SCCS关键词扩展),则可能会产生问题。



Browsing through the git documentation, I can't see anything analogous to SVN's commit hooks or the "propset" features that can, say, update a version number or copyright notice within a file whenever it is committed to the repository.

Are git users expected to write external scripts for this sort of functionality (which doesn't seem out of the question) or have I just missed something obvious?

Edit : Just to be clear, I'm more interested in, e.g.,

svn propset svn:keywords "Author Date Id Revision" expl3.dtx

where a string like this:

$Id: expl3.dtx 780 2008-08-30 12:32:34Z morten $

is kept up-to-date with the relevant info whenever a commit occurs.

解决方案

Quoting from the Git FAQ:

Does git have keyword expansion?

Not recommended. Keyword expansion causes all sorts of strange problems and isn't really useful anyway, especially within the context of an SCM. Outside git you may perform keyword expansion using a script. The Linux kernel export script does this to set the EXTRA_VERSION variable in the Makefile.

See gitattributes(5) if you really want to do this. If your translation is not reversible (eg SCCS keyword expansion) this may be problematic.

这篇关于git是否有像`svn propset svn:keywords`或pre / post-commit hooks之类的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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