gogits/gogs — pull request #284 by compressed (2014-07-12 01:03:36+00:00)
Title: Only update access usernames where the username is changing

Updated PR to dev branch.
--
I did some debugging on #282. I think there are two issues here.

The current process (from what I understand) seems to flow like this:

1. The user's name who is changing has all his/her access records updated
2. Then all the access records for the user's repos are updated, including the records updated in the first case. These updates aren't needed.
3. During the second update, the username for ALL the access records is being set to the new user. This triggers the constraint violation because users A's access record is being changed to B2 (and B2's access record already was updated from B to B2).

This change addresses these two problems by only updating the access records not belonging to the user whose name is being changed in the second pass.