views:

24

answers:

1

I want a way to have my code style do something like this.. this comment is in PHP but the concept should work for any eclipse compatible language.

/*
 * @author ${user}
 * @version ${version}
*/

I would want to update the version variable once, then commit to the repository. So, now when others add comments it would include the Version. This is where the issue comes.. where do you store the Version? Can I just create a <version></version> set of tags in the '.project' file and some how reference them from the code styles?

+1  A: 

In this kind of situtation, provided you are using Subversion, I would use its Keywords substitution mecanism (quoting) :

Subversion has the ability to substitute keywords—pieces of useful, dynamic information about a versioned file—into the contents of the file itself. Keywords generally provide information about the last modification made to the file.

Here, you'd probably be interested by the keywords Revision, and Author, I suppose :

Revision
This keyword describes the last known revision in which this file changed in the repository, and looks something like $Revision: 144 $.

Author
This keyword describes the last known user to change this file in the repository, and looks something like $Author: harry $.

Pascal MARTIN
I use GIT, but I'm not sure how I feel about the Keywords feature in the first place. http://www.gelato.unsw.edu.au/archives/git/0610/28891.html
James Armstead
I've never used git -- but I've never run into any kind of problem with SVN's keywords (about the "binary problem", just don't set that property on binary files... ) ; and I'm probably not the only one using it (I've seen it used for large OSS projects like Zend Framework and Drupal, for instance)
Pascal MARTIN