How do I change the default author for accessing a local SVN repository?

岁酱吖の 提交于 2019-11-30 08:59:23

问题


I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name?

I know how to change author after commit but how to change before? Installing apache/svnserver is not an option.


回答1:


Yes, it's possible.

TortoiseSVN and the svn command line client share the same settings location in your profile folder. So you may simply checkout one version using svn.exe:

$ svn co --username different_user_name file:///C:/path/to/your/repo

... and Subversion will happily replace the associated username for that repository. New commits from TortoiseSVN will then always use that username, no matter with what program you make the new checkouts.

The procedure should work with TortoiseSVN 1.5.5. If it doesn't, try emptying svn's authentication cache (%APPDATA%\Subversion\auth\svn.username) first.




回答2:


Another possible workaround (but I am NOT advocating it) is to use a client-side hook script before commit, in order to change the username.

Hook scripts are discussed in the Subversion book, and local hooks are discussed in "Client Side Hook Scripts" in TortoiseSVN help.




回答3:


As far as I know, TortoiseSVN does not offer any way to do this.

Presumably it's not seen as a big issue, since file based access is not practical for multi-user scenarios, and for single-user the author-name is of lesser importance.

A possible workaround would be to create another Windows username with the author name you want and connect with this.




回答4:


I've never hosted svn on a Windows machine, so this is a shot in the dark. You might be able to create a new Windows user and specify that user when browsing, checking out, committing, etc. Let's say you want to make changes as msznajder. Create a user with that name in Windows, then try browsing the repository using TortoiseSVN's Repo-browser and specify the username in the URL - something like file:///msznajder@localhost/some/file/path.




回答5:


I suggest setting a post-commit-hook (in your repo's hooks folder - just copy the post-commit-hook.tmpl to post-commit-hook.bat and empty it [1]

svn propset svn:author --revprop -r HEAD <author> file:///<path-to-repo> [2]

[1] provided SlikSvn or similar is installed, i.e. commandline svn access is possible)

[2] (or .sh if on linux, with the #!/bin/bash preamble) with the same content



来源:https://stackoverflow.com/questions/45624/how-do-i-change-the-default-author-for-accessing-a-local-svn-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!