summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-02-22 23:33:13 -0500
committer无闻 <u@gogs.io>2015-02-22 23:33:13 -0500
commit125fe92a19291ac0661e4f49c0775c67815d8965 (patch)
tree52000cd8cea030e8336afc0fab9b0bbdf672c7ea
parentfc4dff1b1727682b9641f9238f583cfade2901be (diff)
parentb6519f78c704bf70b48e63f960ef88d430e07b3b (diff)
downloadgitea-125fe92a19291ac0661e4f49c0775c67815d8965.tar.gz
gitea-125fe92a19291ac0661e4f49c0775c67815d8965.zip
Merge pull request #961 from phsmit/access_removecoll
Remove collaborators when removing and transferring repository
-rw-r--r--models/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index fd00823a23..388bcd0e5b 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -670,6 +670,19 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
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.
if _, err = sess.Exec("UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", newUser.Id); err != nil {
return err
@@ -778,6 +791,8 @@ func DeleteRepository(uid, repoId int64, userName string) error {
return err
} else if _, err = sess.Delete(&Release{RepoId: repoId}); err != nil {
return err
+ } else if _, err = sess.Delete(&Collaboration{RepoID: repoId}); err != nil {
+ return err
}
// Delete comments.