Skip to content
Snippets Groups Projects
Commit 0d44f4d5 authored by Mark Chao's avatar Mark Chao
Browse files

Rephrase "maintainer" to more precise "members who can merge to the target branch"

"Maintainer" will be freed to be used for #42751
parent 76c23de3
No related branches found
No related tags found
No related merge requests found
Showing
with 96 additions and 37 deletions
Loading
Loading
@@ -265,10 +265,10 @@ export default {
/>
 
<section
v-if="mr.maintainerEditAllowed"
v-if="mr.allowCollaboration"
class="mr-info-list mr-links"
>
{{ s__("mrWidget|Allows edits from maintainers") }}
{{ s__("mrWidget|Allows commits from members who can merge to the target branch") }}
</section>
 
<mr-widget-related-links
Loading
Loading
Loading
Loading
@@ -83,7 +83,7 @@ export default class MergeRequestStore {
this.canBeMerged = data.can_be_merged || false;
this.isMergeAllowed = data.mergeable || false;
this.mergeOngoing = data.merge_ongoing;
this.maintainerEditAllowed = data.allow_maintainer_to_push;
this.allowCollaboration = data.allow_collaboration;
 
// Cherry-pick and Revert actions related
this.canCherryPickInCurrentMR = currentUser.can_cherry_pick_on_current_merge_request || false;
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
 
def merge_request_params_attributes
[
:allow_maintainer_to_push,
:allow_collaboration,
:assignee_id,
:description,
:force_remove_source_branch,
Loading
Loading
Loading
Loading
@@ -126,8 +126,8 @@ module MergeRequestsHelper
link_to(url[merge_request.project, merge_request], data: data_attrs, &block)
end
 
def allow_maintainer_push_unavailable_reason(merge_request)
return if merge_request.can_allow_maintainer_to_push?(current_user)
def allow_collaboration_unavailable_reason(merge_request)
return if merge_request.can_allow_collaboration?(current_user)
 
minimum_visibility = [merge_request.target_project.visibility_level,
merge_request.source_project.visibility_level].min
Loading
Loading
Loading
Loading
@@ -1124,21 +1124,21 @@ class MergeRequest < ActiveRecord::Base
project.merge_requests.merged.where(author_id: author_id).empty?
end
 
def allow_maintainer_to_push
maintainer_push_possible? && super
def allow_collaboration
collaborative_push_possible? && super
end
 
alias_method :allow_maintainer_to_push?, :allow_maintainer_to_push
alias_method :allow_collaboration?, :allow_collaboration
 
def maintainer_push_possible?
def collaborative_push_possible?
source_project.present? && for_fork? &&
target_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE &&
source_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE &&
!ProtectedBranch.protected?(source_project, source_branch)
end
 
def can_allow_maintainer_to_push?(user)
maintainer_push_possible? &&
def can_allow_collaboration?(user)
collaborative_push_possible? &&
Ability.allowed?(user, :push_code, source_project)
end
 
Loading
Loading
Loading
Loading
@@ -1973,18 +1973,18 @@ class Project < ActiveRecord::Base
.limit(1)
.select(1)
source_of_merge_requests.opened
.where(allow_maintainer_to_push: true)
.where(allow_collaboration: true)
.where('EXISTS (?)', developer_access_exists)
end
 
def branch_allows_maintainer_push?(user, branch_name)
def branch_allows_collaboration?(user, branch_name)
return false unless user
 
cache_key = "user:#{user.id}:#{branch_name}:branch_allows_push"
 
memoized_results = strong_memoize(:branch_allows_maintainer_push) do
memoized_results = strong_memoize(:branch_allows_collaboration) do
Hash.new do |result, cache_key|
result[cache_key] = fetch_branch_allows_maintainer_push?(user, branch_name)
result[cache_key] = fetch_branch_allows_collaboration?(user, branch_name)
end
end
 
Loading
Loading
@@ -2126,18 +2126,18 @@ class Project < ActiveRecord::Base
raise ex
end
 
def fetch_branch_allows_maintainer_push?(user, branch_name)
def fetch_branch_allows_collaboration?(user, branch_name)
check_access = -> do
next false if empty_repo?
 
merge_request = source_of_merge_requests.opened
.where(allow_maintainer_to_push: true)
.where(allow_collaboration: true)
.find_by(source_branch: branch_name)
merge_request&.can_be_merged_by?(user)
end
 
if RequestStore.active?
RequestStore.fetch("project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_maintainer_push") do
RequestStore.fetch("project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_collaboration") do
check_access.call
end
else
Loading
Loading
Loading
Loading
@@ -14,8 +14,8 @@ module Ci
@subject.triggered_by?(@user)
end
 
condition(:branch_allows_maintainer_push) do
@subject.project.branch_allows_maintainer_push?(@user, @subject.ref)
condition(:branch_allows_collaboration) do
@subject.project.branch_allows_collaboration?(@user, @subject.ref)
end
 
rule { protected_ref }.policy do
Loading
Loading
@@ -25,7 +25,7 @@ module Ci
 
rule { can?(:admin_build) | (can?(:update_build) & owner_of_job) }.enable :erase_build
 
rule { can?(:public_access) & branch_allows_maintainer_push }.policy do
rule { can?(:public_access) & branch_allows_collaboration }.policy do
enable :update_build
enable :update_commit_status
end
Loading
Loading
Loading
Loading
@@ -4,13 +4,13 @@ module Ci
 
condition(:protected_ref) { ref_protected?(@user, @subject.project, @subject.tag?, @subject.ref) }
 
condition(:branch_allows_maintainer_push) do
@subject.project.branch_allows_maintainer_push?(@user, @subject.ref)
condition(:branch_allows_collaboration) do
@subject.project.branch_allows_collaboration?(@user, @subject.ref)
end
 
rule { protected_ref }.prevent :update_pipeline
 
rule { can?(:public_access) & branch_allows_maintainer_push }.policy do
rule { can?(:public_access) & branch_allows_collaboration }.policy do
enable :update_pipeline
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ class MergeRequestWidgetEntity < IssuableEntity
expose :squash
expose :target_branch
expose :target_project_id
expose :allow_maintainer_to_push
expose :allow_collaboration
 
expose :should_be_rebased?, as: :should_be_rebased
expose :ff_only_enabled do |merge_request|
Loading
Loading
Loading
Loading
@@ -38,8 +38,8 @@ module MergeRequests
def filter_params(merge_request)
super
 
unless merge_request.can_allow_maintainer_to_push?(current_user)
params.delete(:allow_maintainer_to_push)
unless merge_request.can_allow_collaboration?(current_user)
params.delete(:allow_collaboration)
end
end
 
Loading
Loading
Loading
Loading
@@ -12,9 +12,9 @@
= _('Contribution')
.col-sm-10
.form-check
= form.check_box :allow_maintainer_to_push, disabled: !issuable.can_allow_maintainer_to_push?(current_user), class: 'form-check-input'
= form.label :allow_maintainer_to_push, class: 'form-check-label' do
= _('Allow edits from maintainers.')
= link_to 'About this feature', help_page_path('user/project/merge_requests/maintainer_access')
= form.check_box :allow_collaboration, disabled: !issuable.can_allow_collaboration?(current_user), class: 'form-check-input'
= form.label :allow_collaboration, class: 'form-check-label' do
= _('Allow commits from members who can merge to the target branch.')
= link_to 'About this feature', help_page_path('user/project/merge_requests/allow_collaboration')
.form-text.text-muted
= allow_maintainer_push_unavailable_reason(issuable)
= allow_collaboration_unavailable_reason(issuable)
- unless can?(current_user, :push_code, @project)
.inline.prepend-left-10
- if @project.branch_allows_maintainer_push?(current_user, selected_branch)
- if @project.branch_allows_collaboration?(current_user, selected_branch)
= commit_in_single_accessible_branch
- else
= commit_in_fork_help
---
title: Rephrasing Merge Request's 'allow edits from maintainer' functionality
merge_request: 19061
author:
type: deprecated
class RenameMergeRequestsAllowMaintainerToPush < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
rename_column_concurrently :merge_requests, :allow_maintainer_to_push, :allow_collaboration
end
def down
cleanup_concurrent_column_rename :merge_requests, :allow_collaboration, :allow_maintainer_to_push
end
end
class CleanupMergeRequestsAllowMaintainerToPushRename < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
cleanup_concurrent_column_rename :merge_requests, :allow_maintainer_to_push, :allow_collaboration
end
def down
rename_column_concurrently :merge_requests, :allow_collaboration, :allow_maintainer_to_push
end
end
Loading
Loading
@@ -1216,7 +1216,7 @@ ActiveRecord::Schema.define(version: 20180529093006) do
t.boolean "discussion_locked"
t.integer "latest_merge_request_diff_id"
t.string "rebase_commit_sha"
t.boolean "allow_maintainer_to_push"
t.boolean "allow_collaboration"
t.boolean "squash", default: false, null: false
end
 
Loading
Loading
Loading
Loading
@@ -650,7 +650,8 @@ POST /projects/:id/merge_requests
| `labels` | string | no | Labels for MR as a comma-separated list |
| `milestone_id` | integer | no | The global ID of a milestone |
| `remove_source_branch` | boolean | no | Flag indicating if a merge request should remove the source branch when merging |
| `allow_maintainer_to_push` | boolean | no | Whether or not a maintainer of the target project can push to the source branch |
| `allow_collaboration` | boolean | no | Allow commits from members who can merge to the target branch |
| `allow_maintainer_to_push` | boolean | no | Deprecated, see allow_collaboration |
| `squash` | boolean | no | Squash commits into a single commit when merging |
 
```json
Loading
Loading
@@ -708,6 +709,7 @@ POST /projects/:id/merge_requests
"squash": false,
"web_url": "http://example.com/example/example/merge_requests/1",
"discussion_locked": false,
"allow_collaboration": false,
"allow_maintainer_to_push": false,
"time_stats": {
"time_estimate": 0,
Loading
Loading
@@ -740,7 +742,8 @@ PUT /projects/:id/merge_requests/:merge_request_iid
| `remove_source_branch` | boolean | no | Flag indicating if a merge request should remove the source branch when merging |
| `squash` | boolean | no | Squash commits into a single commit when merging |
| `discussion_locked` | boolean | no | Flag indicating if the merge request's discussion is locked. If the discussion is locked only project members can add, edit or resolve comments. |
| `allow_maintainer_to_push` | boolean | no | Whether or not a maintainer of the target project can push to the source branch |
| `allow_collaboration` | boolean | no | Allow commits from members who can merge to the target branch |
| `allow_maintainer_to_push` | boolean | no | Deprecated, see allow_collaboration |
 
Must include at least one non-required attribute from above.
 
Loading
Loading
@@ -798,6 +801,7 @@ Must include at least one non-required attribute from above.
"squash": false,
"web_url": "http://example.com/example/example/merge_requests/1",
"discussion_locked": false,
"allow_collaboration": false,
"allow_maintainer_to_push": false,
"time_stats": {
"time_estimate": 0,
Loading
Loading
# Allow collaboration on merge requests across forks
> [Introduced][ce-17395] in GitLab 10.6.
This feature is available for merge requests across forked projects that are
publicly accessible. It makes it easier for members of projects to
collaborate on merge requests across forks.
When enabled for a merge request, members with merge access to the target
branch of the project will be granted write permissions to the source branch
of the merge request.
The feature can only be enabled by users who already have push access to the
source project, and only lasts while the merge request is open.
Enable this functionality while creating or editing a merge request:
![Enable collaboration](./img/allow_collaboration.png)
[ce-17395]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17395
doc/user/project/merge_requests/img/allow_collaboration.png

38.6 KiB

doc/user/project/merge_requests/img/allow_maintainer_push.png

48.1 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment