mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-24 21:34:36 -04:00
Merge pull request #961 from phsmit/access_removecoll
Remove collaborators when removing and transferring repository
This commit is contained in:
commit
125fe92a19
@ -670,6 +670,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
|
||||||
@ -778,6 +791,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.
|
||||||
|
Loading…
Reference in New Issue
Block a user