summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-02-22 23:34:05 -0500
committerUnknwon <u@gogs.io>2015-02-22 23:34:05 -0500
commite90f014e4a85d163c68ffb2d1d0e5ea888e9b569 (patch)
tree4ab13aa0452ee7f4272e01edf83ec1d28689c79d /models/repo.go
parent10e4b5b6c66d1a1a17d975dea28b090eaa404cad (diff)
parent125fe92a19291ac0661e4f49c0775c67815d8965 (diff)
downloadgitea-e90f014e4a85d163c68ffb2d1d0e5ea888e9b569.tar.gz
gitea-e90f014e4a85d163c68ffb2d1d0e5ea888e9b569.zip
Merge branch 'access' of github.com:gogits/gogs into access
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index 90cfdba854..bfa5925c35 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -669,6 +669,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
@@ -777,6 +790,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.