Is there a way to change a SVN users username through the entire repository history?

后端 未结 7 1374
太阳男子
太阳男子 2020-12-02 17:55

When my team first started out with SVN we all just used our first names when committing to the repository, however, now that our team has grown, we are running into issues

7条回答
  •  有刺的猬
    2020-12-02 18:27

    On the repository server, you can:

    echo -n "msmith" > msmith.txt
    svn log /svn -q | grep '^r[0-9]* | Mike |' | cut -f 1 -d' ' | xargs -n1 svnadmin setrevprop /svn svn:author msmith.txt -r
    

    Here's what that's doing:

    1. Store the new username in a file with no newline at the end (echo -n)
    2. Get the full log for the repository in /svn, displaying only the summary info (not the log message) (svn log -q)
    3. Find lines with Mike (grep). Note: in most cases, something like grep Mike would do just fine, but if you had a user named Jul, you risk updating every commit made in July (more or less risk depending on your locale)
    4. Filter out everything except the first field (the revision #) (cut)
    5. Run a svnadmin command on every revision found in step 4 (xargs). Only pass one revision per execution of the command (-n1). That will replace the svn:author property with the contents of the msmith.txt file.

提交回复
热议问题