Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggest] change merge strategy: do not check write access if user in merge white list #10951

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fe6d2e3
[suggest] change merge strategy: do not check write access if user in…
everhopingandwaiting Apr 4, 2020
4aa47e7
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 4, 2020
cfd30af
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 4, 2020
7755e10
fix NPE
everhopingandwaiting Apr 4, 2020
dff428f
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 5, 2020
cbbb402
Merge branch 'master' into patch-2-merge-strategy-temp
zeripath Apr 5, 2020
f1edeb9
Fix cross compile (#10952)
lunny Apr 5, 2020
dc1a473
fix merge box icon color bug (#10974)
a1012112796 Apr 5, 2020
7f49034
[skip ci] Updated translations via Crowdin
GiteaBot Apr 5, 2020
87c4bc1
Allow X in addition to x in tasks (#10979)
zeripath Apr 5, 2020
6e94a61
remove api: merge reqRepoWriter
everhopingandwaiting Apr 6, 2020
d931ea2
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 6, 2020
fe38a93
Merge branch 'master' into patch-2-merge-strategy-temp
techknowlogick Apr 7, 2020
fa27e5b
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 7, 2020
fc0e25d
Merge branch 'master' into patch-2-merge-strategy-temp
everhopingandwaiting Apr 7, 2020
0352a86
Merge branch 'master' into patch-2-merge-strategy-temp
techknowlogick Apr 7, 2020
ff1fb2e
Merge branch 'master' into patch-2-merge-strategy-temp
zeripath Apr 7, 2020
cf9bade
Merge branch 'master' into patch-2-merge-strategy-temp
guillep2k Apr 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Combo("").Get(repo.GetPullRequest).
Patch(reqToken(), reqRepoWriter(models.UnitTypePullRequests), bind(api.EditPullRequestOption{}), repo.EditPullRequest)
m.Combo("/merge").Get(repo.IsPullRequestMerged).
Post(reqToken(), mustNotBeArchived, reqRepoWriter(models.UnitTypePullRequests), bind(auth.MergePullRequestForm{}), repo.MergePullRequest)
Post(reqToken(), mustNotBeArchived, bind(auth.MergePullRequestForm{}), repo.MergePullRequest)
})
}, mustAllowPulls, reqRepoReader(models.UnitTypeCode), context.ReferencesGitRepo(false))
m.Group("/statuses", func() {
Expand Down
3 changes: 1 addition & 2 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ func RegisterRoutes(m *macaron.Macaron) {
reqRepoWikiWriter := context.RequireRepoWriter(models.UnitTypeWiki)
reqRepoIssueWriter := context.RequireRepoWriter(models.UnitTypeIssues)
reqRepoIssueReader := context.RequireRepoReader(models.UnitTypeIssues)
reqRepoPullsWriter := context.RequireRepoWriter(models.UnitTypePullRequests)
reqRepoPullsReader := context.RequireRepoReader(models.UnitTypePullRequests)
reqRepoIssuesOrPullsWriter := context.RequireRepoWriterOr(models.UnitTypeIssues, models.UnitTypePullRequests)
reqRepoIssuesOrPullsReader := context.RequireRepoReaderOr(models.UnitTypeIssues, models.UnitTypePullRequests)
Expand Down Expand Up @@ -887,7 +886,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get(".diff", repo.DownloadPullDiff)
m.Get(".patch", repo.DownloadPullPatch)
m.Get("/commits", context.RepoRef(), repo.ViewPullCommits)
m.Post("/merge", context.RepoMustNotBeArchived(), reqRepoPullsWriter, bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/merge", context.RepoMustNotBeArchived(), bindIgnErr(auth.MergePullRequestForm{}), repo.MergePullRequest)
m.Post("/update", repo.UpdatePullRequest)
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
m.Group("/files", func() {
Expand Down
5 changes: 1 addition & 4 deletions services/pull/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,13 @@ func IsSignedIfRequired(pr *models.PullRequest, doer *models.User) (bool, error)

// IsUserAllowedToMerge check if user is allowed to merge PR with given permissions and branch protections
func IsUserAllowedToMerge(pr *models.PullRequest, p models.Permission, user *models.User) (bool, error) {
if !p.CanWrite(models.UnitTypeCode) {
return false, nil
}

err := pr.LoadProtectedBranch()
if err != nil {
return false, err
}

if pr.ProtectedBranch == nil || pr.ProtectedBranch.IsUserMergeWhitelisted(user.ID) {
if (p.CanWrite(models.UnitTypeCode) && pr.ProtectedBranch == nil) || (pr.ProtectedBranch != nil && pr.ProtectedBranch.IsUserMergeWhitelisted(user.ID)) {
return true, nil
}

Expand Down