aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2022-03-08 22:48:47 +0100
committerGitHub <noreply@github.com>2022-03-08 22:48:47 +0100
commiteceab9e26f671318d3b50e622736a514f384aee6 (patch)
treeac83f24a8114aaef59e0ef225f4a2bfccbb8b179 /models/repo.go
parente73c5fd698a8979a015c43625941aa82ac7a8bf9 (diff)
downloadgitea-eceab9e26f671318d3b50e622736a514f384aee6.tar.gz
gitea-eceab9e26f671318d3b50e622736a514f384aee6.zip
Allow users to self-request a PR review (#19030)
The review request feature was added in https://github.com/go-gitea/gitea/pull/10756, where the doer got explicitly excluded from available reviewers. I don't see a functionality or security related reason to forbid this case. As shown by GitHubs implementation, it may be useful to self-request a review, to be reminded oneselves about reviewing, while communicating to team mates that a review is missing. Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index 38527c74dc..53199bcca3 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -225,13 +225,21 @@ func getReviewers(ctx context.Context, repo *repo_model.Repository, doerID, post
// This a private repository:
// Anyone who can read the repository is a requestable reviewer
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 ( ?, ?)) ORDER BY name",
+ SQL("SELECT * FROM `user` WHERE id in ("+
+ "SELECT user_id FROM `access` WHERE repo_id = ? AND mode >= ? AND user_id != ?"+ // private org repos
+ ") ORDER BY name",
repo.ID, perm.AccessModeRead,
- doerID, posterID).
+ posterID).
Find(&users); err != nil {
return nil, err
}
+ if repo.Owner.Type == user_model.UserTypeIndividual && repo.Owner.ID != posterID {
+ // as private *user* repos don't generate an entry in the `access` table,
+ // the owner of a private repo needs to be explicitly added.
+ users = append(users, repo.Owner)
+ }
+
return users, nil
}
@@ -244,11 +252,11 @@ func getReviewers(ctx context.Context, repo *repo_model.Repository, doerID, post
"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",
+ ") AND id != ? ORDER BY name",
repo.ID, perm.AccessModeRead,
repo.ID, repo_model.WatchModeNormal, repo_model.WatchModeAuto,
repo.OwnerID,
- doerID, posterID).
+ posterID).
Find(&users); err != nil {
return nil, err
}