Eclipse Git关键字扩展 [英] Eclipse Git keyword expansion

查看:179
本文介绍了Eclipse Git关键字扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要更新我的源代码修订关键字正如你可能知道的那样:


这个在Git中的主要问题是你不能用
修改一个文件因为Git
首先对文件进行校验。


基本上我想要实现的是是我的源代码应该如下所示:

  * Git修订信息:
*
* @版本$修订:1e7f611039399b32e9000ec454609a0641dde368 $
* @author $作者:欧根米哈伊列斯库< eugenmihailescux@gmail.com> $
* @date $日期:星期四5月3日01:17:45 2012 +0200 $
*
* $ Id:|星期四5月3日01:17:45 2012 +0200 | Eugen Mihailescu

这里这里你可以找到如何在Git中实现这一点。


事实证明,您可以编写自己的过滤器来执行
在提交/结帐时替换文件。这些是干净的和
污迹过滤器。在.gitattributes文件中,您可以为
特定路径设置一个过滤器,然后设置脚本在检出之前处理文件
(污迹,见图7-2)和就在
之前他们就提交了。


所以我知道如何用git命令来做到这一点。我已经测试过,它只是起作用!
我真正的问题是我想通过使用Eclipse IDE来实现同样的目标。
在Eclipse中,我有Eclipse Git,它是一个基于JGit的Eclipse Team提供程序,它是Git版本控制系统的纯Java实现。

在Eclipse EGit中,

没有这样的命令git checkout,但可以通过硬重置来完成该操作(右键单击您的项目,然后选择Team - > Reset - > Hard)。不幸的是,这不会运行您的干净/污迹过滤器,事实上,您将从git中心获得源代码的普通副本,而不会扩展关键字。



我希望我已经详细描述了整个故事,因为现在我会问:


  • 在Eclipse中使用EGit可以实现这一点吗?


解决方案

提交(2010年8月)发表了评论



执行自动CRLF WorkingTreeIterator期间LF转换




WorkingTreeIterator 现在可以选择对文本文件执行CRLF到LF的转换。

基于 gitattributes 支持启用(或禁用)此功能的基本框架,并支持更通用的涂抹/清洁过滤系统。

As there在JGit中没有 gitattribute 支持,但它仍未实现,但 mightNeedCleaning() isBinary() filterClean()方法将提供合理的位置以便将来插入。


< blockquote>

我不认为在 gitattribute 。组织/ JGit / New_and_Noteworthy 相对= nofollow>最新版本JGit 的,而 WorkingTreeIterator 的nofollow的>最新版本仍然具有一个空 filterClean()函数。

因此单独使用JGit可能不足以触发您的过滤器内容驱动程序。

I need to to update my source code revision keywords (@version, @date, etc) every time I am checking out the source to the git-hub server.

As you might know:

The main problem with this in Git is that you can’t modify a file with information about the commit after you’ve committed, because Git checksums the file first.

Basically what I want to achieve is that my source code should look like below:

 * Git revision information:
 * 
 * @version $Revision: 1e7f611039399b32e9000ec454609a0641dde368 $
 * @author  $Author: Eugen Mihailescu <eugenmihailescux@gmail.com> $
 * @date    $Date:   Thu May 3 01:17:45 2012 +0200 $
 * 
 * $Id:  | Thu May 3 01:17:45 2012 +0200 | Eugen Mihailescu  $

Here and here you can find a full description of how you can achieve this in Git.

It turns out that you can write your own filters for doing substitutions in files on commit/checkout. These are the "clean" and "smudge" filters. In the .gitattributes file, you can set a filter for particular paths and then set up scripts that will process files just before they’re checked out ("smudge", see Figure 7-2) and just before they’re committed.

So I know how to do it with git command. I've tested, it just works! My real issue is that I would like to achieve same thing by using Eclipse IDE. In Eclipse I have Eclipse Git, which is an Eclipse Team provider based on JGit, a pure Java implementation of the Git version control system.

In Eclipse EGit there is no such command "git checkout" but one could accomplish that by a hard reset (right-click your project then choose Team -> Reset -> Hard). Unfortunately this will not run your clean/smudge filters, in fact you will get the plain copy of your sources from the git hub without no keyword expansion.

I hope that I have described in detail the whole story because now I will ask:

  • is this possible in Eclipse using the EGit?

解决方案

This commit (August 2010) commented

Perform automatic CRLF to LF conversion during WorkingTreeIterator

WorkingTreeIterator now optionally performs CRLF to LF conversion for text files.
A basic framework is left in place to support enabling (or disabling) this feature based on gitattributes, and also to support the more generic smudge/clean filter system.
As there is no gitattribute support yet in JGit this is left unimplemented, but the mightNeedCleaning(), isBinary() and filterClean() methods will provide reasonable places to plug that into in the future.

I don't think gitattribute is fully supported in the latest JGit releases, and the latest revision of WorkingTreeIterator has still an empty filterClean() function.

So using JGit alone might not be enough to trigger your "filter content" driver.

这篇关于Eclipse Git关键字扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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