Include SVN revision number in source code

后端 未结 5 962
生来不讨喜
生来不讨喜 2020-12-09 10:23

My requirement is simple. At the beginning of each file there should be a block comment like this:

/*
 * This file was last modified by {username} at {date}          


        
5条回答
  •  生来不讨喜
    2020-12-09 10:45

    I followed Petar Minchev's suggestions, only I put the $LastChangedRevision$ tag not in a comment block but embedded it in a string. Now it is available to programmatically display the revision number in a Help -> About dialog.

    String build = "$LastChangedRevision$";
    

    I can later display the revision value in the about dialog using a String that has all of the fluff trimmed off.

    String version = build.replace("$LastChangedRevision:", "").replace("$", "").trim();
    

提交回复
热议问题