1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-22 08:42:32 -05:00

Merge branch 'access' of github.com:gogits/gogs into access

This commit is contained in:
Unknwon 2015-02-22 23:34:05 -05:00
commit e90f014e4a

View file

@ -669,6 +669,19 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
return err return err
} }
// Remove redundant collaborators
collaborators, err := repo.GetCollaborators()
if err != nil {
return err
}
for _, c := range collaborators {
if c.Id == newUser.Id || newUser.IsOrgMember(c.Id) {
if _, err = sess.Delete(&Collaboration{RepoID: repo.Id, UserID: c.Id}); err != nil {
return err
}
}
}
// Update user repository number. // Update user repository number.
if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", newUser.Id); err != nil { if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", newUser.Id); err != nil {
return err return err
@ -777,6 +790,8 @@ func DeleteRepository(uid, repoId int64, userName string) error {
return err return err
} else if _, err = sess.Delete(&Release{RepoId: repoId}); err != nil { } else if _, err = sess.Delete(&Release{RepoId: repoId}); err != nil {
return err return err
} else if _, err = sess.Delete(&Collaboration{RepoID: repoId}); err != nil {
return err
} }
// Delete comments. // Delete comments.