Include SVN revision number in source code

后端 未结 5 949
生来不讨喜
生来不讨喜 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:39

    I recommend a slightly different approach.

    Put the following header at the top of your source files.

    /*
     * This file was last modified by {username} at {date} and has revision number {revisionnumber}
     */
    

    Then add a shell script like this

    post update, checkout script

    USERNAME=# // use svnversion to get username
    DATE=# // use svnversion to get revisio nnumber
    sed -e "s#{username}#${USERNAME}#" -e "s#{date}#${DATE}#" ${SOURCE_CONTROL_FILE} > ${SOURCE_FILE}
    

    pre commit script

    cat standard_header.txt > ${SOURCE_CONTROL_FILE}
    tail --lines $((${LENGTH}-4)) ${SOURCE_FILE} >> ${SOURCE_CONTROL_FILE}
    

提交回复
热议问题