Changing username in SVN+SSH URI on the fly in wor

2019-03-25 04:07发布

I am using SVN+SSH to check out a working copy of repository from an SVN server on which all developers are members of a developer group and have full read/write permissions on the repository directory and associated metadata:

svn co svn+ssh://someuser@svn.server/path/to/repository

Several developers work on the same working copy that is checked out under a shared shell account (root). Because this repository is being used for configuration revision control in a production environment, this is unavoidable. Giving each developer an individual shell account on the target machine (the one on which the checkout is being done) would be one way to solve this problem because then they could each have their own working copy, but unfortunately this is not acceptable here.

We have various post-commit hooks that send e-mails detailing commits, including the username of the person that committed the change.

The problem is that once a working copy is checked out with a given username using the svn+ssh:// URI scheme, commits and updates seem to also have to be done under that username. This is not viable for two reasons:

1) The person who originally made the checkout may not be the person making a commit now, and we need the post-commit e-mails and other post-commit hooks to know exactly who made the commit, and

2) clearly, a commit requires that the committing user know the password of the account of the person who made the original checkout, the use of RSA keys for non-interactive authentication notwithstanding for reason #1.

Is there a way to do dynamically switch out the username of the remote account that is being used for authentication in this scenario?

I did some research and found this question previously:

Changing the username for a Subversion commit over svn+ssh

Unfortunately, the suggestion in the accepted answer (svn switch) does not work:

[root@db repo-directory]# svn switch svn+ssh://user2@10.250.10.1/u/svc/repositories/repo-name
user2@10.250.10.1's password: 
svn: 'svn+ssh://user1@10.250.10.1/u/svc/repositories/repo-name' is not the same
repository as 'svn+ssh://user2@10.250.10.1/u/svc/repositories/repo-name'

Any ideas would be greatly appreciated. Thank you in advance for your consideration!

3条回答
ら.Afraid
2楼-- · 2019-03-25 04:20

Ah, well, never mind. It seems that svn switch --relocate does the trick:

svn switch --relocate svn+ssh://olduser@svn.server/path/to/repo svn+ssh://newuser@svn.server/path/to/repo

It's cumbersome, though. If there's any easier way, I'm open to suggestions.

Obviously, one can write a bash alias or shell-script to automate this part, I suppose, but I wish it were simpler than that.

查看更多
Evening l夕情丶
3楼-- · 2019-03-25 04:36

It works with ssh+svn if you modify your client's config: $HOME/.subversion/config tunnels section:

ssh = $SVN_SSH ssh -l *youruser*
查看更多
smile是对你的礼貌
4楼-- · 2019-03-25 04:39

You could do a simple update with another username, too.

svn update --username <user> --password <pwd>
查看更多
登录 后发表回答