gpt4 book ai didi

Eclipse Git 关键字扩展

转载 作者:太空狗 更新时间:2023-10-29 13:46:10 25 4
gpt4 key购买 nike

每次我将源 checkout 到 git-hub 服务器时,我都需要更新我的源代码修订关键字(@version、@date 等)。

你可能知道:

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.

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

 * 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 $

Herehere您可以找到有关如何在 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.

所以我知道如何使用 git 命令来完成它。我已经测试过了,它确实有效!我真正的问题是我想通过使用 Eclipse IDE 来实现同样的事情。在 Eclipse 中,我有 Eclipse Git,它是基于 JGit 的 Eclipse Team 提供程序,JGit 是 Git 版本控制系统的纯 Java 实现。

在 Eclipse EGit 中没有这样的命令“git checkout”,但可以通过硬重置来完成(右键单击您的项目,然后选择团队 -> 重置 -> 硬重置)。不幸的是,这不会运行你的干净/污迹过滤器,事实上你会从 git hub 获得你的源代码的普通副本,没有关键字扩展。

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

  • 在使用 EGit 的 Eclipse 中这可能吗?

最佳答案

commit (August 2010)评论

在 WorkingTreeIterator 期间执行自动 CRLF 到 LF 转换

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.

我不认为 gitattributelatest JGit releases 中得到完全支持, 和 latest revision of WorkingTreeIterator仍然有一个空的 filterClean() 函数。

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

关于Eclipse Git 关键字扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10426402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com