0

I'm currently migrating repositories and have created some key variables to use in my Subversion commit, the most important of those are Commit message, and Date I am trying to commit with those variables as part of the svn ci operation, the message is fairly easy as I can use svn ci -m"$(LOGMSG)" for the message, but I have no idea how to explicitly add the DATE and AUTHOR fields to the commit, could someone help?

for (( r=$CURREV; r<$ENDREV+1; r++ ))
do

  git svn fetch -r $CURREV

  # move whitelists subversion folder
  find "$GIT_FOLDER" \
    -mindepth 1 \
    -maxdepth 1 \
    -regextype posix-egrep \
    -not -regex ".*/(${EXCLUDE_PATTERN})$" \
    -exec mv -t "$SVN_FOLDER" '{}' '+'

    # set opts for SVN logging
    CID=$(git log --format=oneline |awk '{print $1}')
    AUTHOR='Jd Daniel <[email protected]>'
    DATE=$(git log --date=iso |grep 'Date' |awk -v N=2 '{sep=""; for (i=N; i<=NF; i++) {printf("%s%s",sep,$i); sep=OFS}; printf("\n")}')
    LOGMSG=$(git log --oneline |awk -v N=2 '{sep=""; for (i=N; i<=NF; i++) {printf("%s%s",sep,$i); sep=OFS}; printf("\n")}')


    # move to svn
    cd $SVN_FOLDER

    ADD=$(svn st |grep '?\|M' |awk '{printf "%s ", $2}'); [  -z "$ADD" ] || svn add $ADD
    REM=$(svn st |grep 'D\|!' |awk '{printf "%s ", $2}'); [  -z "$REM" ] || svn rm  $REM

    # do commit
    svn ci -m 'GIT ID: '$CID$'\n'$LOGMSG


  break # just on rev for now

done
1

1 Answer 1

1

You can change the author and date of an already committed revision with the command svn propset --revprop. The following two commands change the properties for the most recent revision:

svn propset --revprop -r HEAD svn:author "$AUTHOR"
svn propset --revprop -r HEAD svn:date "$DATE"

The date should be in the format YYYY-mm-ddTHH:MM:SS.MSZ. See the output of the following command for reference:

svn propget --revprop -r HEAD svn:date

Unfortunately, you have to change each property separately. The command svn commit has also an option for revision properties (--with-revprop). However, this option can not be used to override standard properties during commit.

The SVN repository must be configured to allow revision property changes. If it is not configured accordingly, you will get an error message. In this case you have to create or change the hook script hooks/pre-revprop-change in the SVN repository. Take a look at the template file hooks/pre-revprop-change.tmpl for more information.

Sign up to request clarification or add additional context in comments.

1 Comment

Looks like it works, unfortunately Redmine is taking forever to update, but an svn log shows this to be working. Accepted and +1 for an awesome answer, thanks brother

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.