diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-20 23:43:26 -0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-21 09:43:26 +0200 |
commit | 515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4 (patch) | |
tree | 3a7143fc376af4402ca9008876be3afdc0c18efc /models/repo.go | |
parent | 529482135c8e9304dd7cdf08772eaba61d903894 (diff) | |
download | gitea-515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4.tar.gz gitea-515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4.zip |
Fix ignored errors when checking if organization, team member (#3177)
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 14 |
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. |