Dave Jarvis
Dave Jarvis

Reputation: 31171

Subversion Keyword for Filename

Background

Customer requests that all source files include the following in the header:

File: filename.ext

Problem

As far as I can tell, Subversion offers the following keywords:

Of those keywords that contain the filename, they all contain more information than the filename.

Question

Short of writing a script hook, what Subversion keyword contains only the filename and nothing else but the file's name and extension (no path, no URL, no author, no revision, etc.)?

To be clear, if the file was named "MyFile.java", then I'd like to see the following automatically added to the header:

/**
 * File: $File:: MyFile.java$
 * ... other keywords ...
 */

Upvotes: 0

Views: 941

Answers (1)

Lazy Badger
Lazy Badger

Reputation: 97282

If your SVN is 1.8+, you can define and use custom keywords (see svn help ps). Substitution pattern %b is that you want:

>svn pl -v data.txt
Properties on 'data.txt':
  svn:keywords
    File=%b

Content of data.txt in repo, without keyword expansion (hard to get today)

//$File$

Data

Content of data.txt in Working Copy

// $File: data.txt $

Data

And full repository tree

>svn ls -R
Data/
Data/Collection/
Data/Collection/data.txt

HTH

Upvotes: 3

Related Questions