任何允许自定义 $Keywords$ 的源代码控制系统? [英] Any source control systems that allow custom defined $Keywords$?

查看:25
本文介绍了任何允许自定义 $Keywords$ 的源代码控制系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何源代码控制系统允许管理员定义自定义关键字,这些关键字在签入时被替换为不同的行为(即类似于 $Id$ 或 $Author$ 等)

I was wondering if there are any source control systems that allow administrators to define custom keywords which are replaced on check in with different behaviours (i.e. similar to $Id$ or $Author$ etc.)

我只熟悉 SVN 和 CVS,它们有一组关键字列表,但会有一些应用程序,例如 $LineNo$ 或 $MyLicenceText$.我相信会有其他用例.我们的想法是创建一个插件架构,在其中可以定义或修改关键字的行为.

I'm only familiar with SVN and CVS which have a set list of keywords, but there would be applications for something like $LineNo$ or $MyLicenceText$. I'm sure there would be other use cases. The idea would be to create a plugin architecture where the behaviour of a keyword could be defined or modified.

所以我的问题是 - 是否有一种工具(商业或开源)已经有类似的东西?

So my question is - is there a tool (commerical or open source) that already has something like that?

将其作为构建的一部分进行是解决问题的有效方法,但是如果开发人员在签入之前没有进行构建,则会导致问题.想象一下像 $LineNo$ 这样的东西,如果构建与源不完全同步,那么值很容易不正确.对于具有更多静态行为的关键字(如 $MyLicenceText$),在构建时替换是一个有效的解决方案.

Doing it as a part of the build is a valid way of solving the problem, however would cause issues if a developer did not do a build prior to check-in. Imagine for something like $LineNo$, if the build was not in sync with the source exactly, the value could easily be incorrect. For keywords with more static behaviour though (like $MyLicenceText$) replacement on build is a valid solution.

推荐答案

您可以查看可以使用 .gitattributes 文件在 Git.这使您可以定义两个转换,称为 smudgeclean,它们可以让您在检出文件时以任意方式转换文件,并在检查时再次将其转换回

You could look at the filter attribute that you can set with a .gitattributes file in Git. This lets you define two transformations, known as smudge and clean, which let you transform a file in any arbitrary way when you check it out and transform it back again when you check it in.

这篇关于任何允许自定义 $Keywords$ 的源代码控制系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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