I use SVN as repository management tool and usually work on multiple projects simultaneously. I was looking for some way using SVN to generate a release notes file that can have version details. Then I got to know about SVN keywords substitution property and I used it to create a release notes for my project.
SVN Provides a list of keywords that you can set on a file and it will dynamically replace that with the latest information at the time of code check in. Some of these keywords are Id, Author, Revision, HeadURL etc.
So to create my release notes file, first of all I added a release.txt file at my project root directory with following information.
release.txt
======================================
Version Number: 0.0.1-SNAPSHOT
======================================
SVN Revision:
-------------
- $Id: $
- $HeadURL: $
Release Notes :
------------------------
- Testing Project
Notice the use of Id and HeadURL, these are the keywords that SVN will replace when I will check in this file. But before that we need to set the svn:keywords
property on this file using below command.
svn propedit svn:keywords release.txt
Add all the keywords that you want to be replaced dynamically space separated, for example “Id HeadURL”.
Now after all my development for a version is finished, I check in this file and the file gets edited dynamically like this.
======================================
Version Number: 0.0.1-SNAPSHOT
======================================
SVN Revision:
-------------
- $Id: release.txt 194 2013-05-31 04:24:20Z pkumar $
- $HeadURL: https://localhost:1080/SVNROOT/SANDBOX/MyProject/release.txt $
Release Notes :
------------------------
- Testing Project
Now every time I just add additional information to the file with release notes data and I can figure out easily which is the last revision number for a version. For example my file looks like below at the time of check in.
======================================
Version Number: 0.0.2-SNAPSHOT
======================================
SVN Revision:
-------------
- $Id: $
- $HeadURL: $
Release Notes :
------------------------
- New Features
======================================
Version Number: 0.0.1-SNAPSHOT
======================================
SVN Revision:
-------------
- $Id: release-notes.txt 194 2013-05-31 04:24:20Z pkumar2
- $HeadURL: https://localhost:1080/SVNROOT/SANDBOX/MyProject/release.txt
Release Notes :
------------------------
- Testing Project
Note that we need to remove the ending $ from keywords in the file else it will also get replaced.
That’s all about SVN keywords substitution example.