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?