summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 40495e4399..7c538525f2 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1493,12 +1493,18 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
// Dummy object.
collaboration := &Collaboration{RepoID: repo.ID}
for _, c := range collaborators {
- collaboration.UserID = c.ID
- if c.ID == newOwner.ID || newOwner.IsOrgMember(c.ID) {
- if _, err = sess.Delete(collaboration); err != nil {
- return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
+ if c.ID != newOwner.ID {
+ isMember, err := newOwner.IsOrgMember(c.ID)
+ if err != nil {
+ return fmt.Errorf("IsOrgMember: %v", err)
+ } else if !isMember {
+ continue
}
}
+ collaboration.UserID = c.ID
+ if _, err = sess.Delete(collaboration); err != nil {
+ return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
+ }
}
// Remove old team-repository relations.