Subversion:在提交时将修订数据添加到代码文件 [英] Subversion: Add revision data to code file on commit

查看:24
本文介绍了Subversion:在提交时将修订数据添加到代码文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以在提交文件时自动将信息插入代码文件本身(如作者、提交评论、提交日期等)?我希望将此信息附加到每个提交文件顶部的块中.基本上整个修订历史应该记录在每个代码文件中......

Is there an easy way to, on commit of a file, automatically insert information into the code file itself (like author, commit comment, commit date, etc)? I would want this information appended to a block at the top of each committed file. Essentially the entire revision history should be documented in each code file...

我看到有一种方法可以使用 subversion 属性来实现类似的功能,但是我看不到如何将实际提交注释放入文件中,也看不到如何保留具有整个修订历史,而不仅仅是最后一次提交信息.

I see there is a way to use subversion properties to achieve something similar, but I don't see how to get the actual commit comment into the file, and also I don't see how to keep a running log that has the entire revision history as opposed to just the last commit information.

我个人认为这不是一个好主意,因为代码文件中应该只包含代码,但不幸的是,这是我当前项目的要求.

I don't personally think this is a good idea as the code file should just have code in it, but unfortunately this is a requirement for my current project.

推荐答案

Subversion 支持多种关键字,如 $Id$$Author$$Revision$ 等.要使用那些你需要设置svn:keywords 属性 相应.但是,您不能像 $Log$ 那样插入提交注释.请参阅 subversion FAQ 了解有关此问题的原因,我只能同意那里给出的理由.将提交注释放入文件中只是被设计破坏了,任何这样的注释都是错误的,因为您无法对照存储库检查它.

Subversion supports various keywords like $Id$, $Author$, $Revision$ and so on. To use those you need to set the svn:keywords property accordingly. However, you can't insert the commit comment like $Log$ does. See the subversion FAQ for the reasons about this, and I can only agree with the reasons given there. Putting the commit comments into the file is simply broken by design, and any such comment is wrong the moment you can't check it against the repository.

其他版本控制系统也不支持这一点,而且大多数都有类似的推理(例如,git).

Other version control systems also don't support this, and most of them with a similar reasoning (for example, git).

请不要争论这样的事情是项目的要求".如果发布的代码必须包含更改历史记录,您可以在使用一些帮助脚本轻松创建发布时添加此历史记录.至少,subversion 根本不支持它.我会强烈阻止尝试通过预提交钩子来实现这一目标.提交钩子应该永远改变提交的数据.

Please don't argue with something like that being a "requirement for the project". If released code has to include a change history you can add this history when creating the release with some helper script rather easily. At least, subversion simply doesn't support it. And I would strongly discourage trying to achive this with a pre-commit hook. Commit hooks should never change the data that gets committed.

这篇关于Subversion:在提交时将修订数据添加到代码文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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