diff options
author | Unknwon <u@gogs.io> | 2016-08-15 18:48:20 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-15 18:48:20 -0700 |
commit | f3c325892139a4dae84ceda773b7caf5aef67d33 (patch) | |
tree | f8773fc623c226e02d4699c3f5d1fc69f4157edb | |
parent | 4042d1f0c3c545773f81e2ca1b4eb8662bc4c425 (diff) | |
download | gitea-f3c325892139a4dae84ceda773b7caf5aef67d33.tar.gz gitea-f3c325892139a4dae84ceda773b7caf5aef67d33.zip |
Fix repository owner can assign self
-rw-r--r-- | models/repo.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/models/repo.go b/models/repo.go index 632f0be713..2eb63f54c5 100644 --- a/models/repo.go +++ b/models/repo.go @@ -325,20 +325,19 @@ func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) { if err = e.Where("repo_id = ? AND mode >= ?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil { return nil, err } - if len(accesses) == 0 { - return []*User{}, nil - } - - userIDs := make([]int64, len(accesses)) - for i := 0; i < len(accesses); i++ { - userIDs[i] = accesses[i].UserID - } // Leave a seat for owner itself to append later, but if owner is an organization // and just waste 1 unit is cheaper than re-allocate memory once. - users := make([]*User, 0, len(userIDs)+1) - if err = e.In("id", userIDs).Find(&users); err != nil { - return nil, err + users := make([]*User, 0, len(accesses)+1) + if len(accesses) > 0 { + userIDs := make([]int64, len(accesses)) + for i := 0; i < len(accesses); i++ { + userIDs[i] = accesses[i].UserID + } + + if err = e.In("id", userIDs).Find(&users); err != nil { + return nil, err + } } if !repo.Owner.IsOrganization() { users = append(users, repo.Owner) |