Skip to content

Commit

Permalink
All organization members should be assignable as reviewer (#14262)
Browse files Browse the repository at this point in the history
For public repos, all organization members should be assignable as reviewer

Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
jpraet and zeripath authored Feb 28, 2021
1 parent 5de7696 commit 3e65286
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,19 @@ func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) ([]*User,
}

// This is a "public" repository:
// Any user that has write access or who is a watcher can be requested to review
// Any user that has read access, is a watcher or organization member can be requested to review
if err := e.
SQL("SELECT * FROM `user` WHERE id IN ( "+
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? AND user_id NOT IN ( ?, ?) "+
"SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? "+
"UNION "+
"SELECT user_id FROM `watch` WHERE repo_id = ? AND user_id NOT IN ( ?, ?) AND mode IN (?, ?) "+
") ORDER BY name",
repo.ID, AccessModeRead, doerID, posterID,
repo.ID, doerID, posterID, RepoWatchModeNormal, RepoWatchModeAuto).
"SELECT user_id FROM `watch` WHERE repo_id = ? AND mode IN (?, ?) "+
"UNION "+
"SELECT uid AS user_id FROM `org_user` WHERE org_id = ? "+
") AND id NOT IN (?, ?) ORDER BY name",
repo.ID, AccessModeRead,
repo.ID, RepoWatchModeNormal, RepoWatchModeAuto,
repo.OwnerID,
doerID, posterID).
Find(&users); err != nil {
return nil, err
}
Expand All @@ -611,8 +615,8 @@ func (repo *Repository) getReviewers(e Engine, doerID, posterID int64) ([]*User,

// GetReviewers get all users can be requested to review:
// * for private repositories this returns all users that have read access or higher to the repository.
// * for public repositories this returns all users that have write access or higher to the repository,
// and all repo watchers.
// * for public repositories this returns all users that have read access or higher to the repository,
// all repo watchers and all organization members.
// TODO: may be we should have a busy choice for users to block review request to them.
func (repo *Repository) GetReviewers(doerID, posterID int64) ([]*User, error) {
return repo.getReviewers(x, doerID, posterID)
Expand Down

0 comments on commit 3e65286

Please sign in to comment.