Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
c9557ad7
Commit
c9557ad7
authored
Feb 27, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow maintainers to push to a single branch
parent
b2ef8385
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
lib/gitlab/user_access.rb
lib/gitlab/user_access.rb
+5
-1
spec/lib/gitlab/user_access_spec.rb
spec/lib/gitlab/user_access_spec.rb
+35
-0
No files found.
lib/gitlab/user_access.rb
View file @
c9557ad7
...
...
@@ -68,8 +68,12 @@ module Gitlab
return
true
if
project
.
user_can_push_to_empty_repo?
(
user
)
protected_branch_accessible_to?
(
ref
,
action:
:
push
)
elsif
user
.
can?
(
:push_code
,
project
)
true
elsif
user
.
can?
(
:push_single_branch
,
project
)
project
.
branches_allowing_maintainer_access_to_user
(
user
).
include?
(
ref
)
else
user
.
can?
(
:push_code
,
project
)
false
end
end
...
...
spec/lib/gitlab/user_access_spec.rb
View file @
c9557ad7
require
'spec_helper'
describe
Gitlab
::
UserAccess
do
include
ProjectForksHelper
let
(
:access
)
{
described_class
.
new
(
user
,
project:
project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -118,6 +120,39 @@ describe Gitlab::UserAccess do
end
end
describe
'allowing pushes to maintainers of forked projects'
do
let
(
:canonical_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:project
)
{
fork_project
(
canonical_project
,
create
(
:user
),
repository:
true
)
}
before
do
create
(
:merge_request
,
target_project:
canonical_project
,
source_project:
project
,
source_branch:
'awesome-feature'
,
allow_maintainer_to_push:
true
)
end
it
'allows users that have push access to the canonical project to push to the MR branch'
do
canonical_project
.
add_developer
(
user
)
expect
(
access
.
can_push_to_branch?
(
'awesome-feature'
)).
to
be_truthy
end
it
'does not allow the user to push to other branches'
do
canonical_project
.
add_developer
(
user
)
expect
(
access
.
can_push_to_branch?
(
'master'
)).
to
be_falsey
end
it
'does not allow the user to push if he does not have push access to the canonical project'
do
canonical_project
.
add_guest
(
user
)
expect
(
access
.
can_push_to_branch?
(
'awesome-feature'
)).
to
be_falsey
end
end
describe
'merge to protected branch if allowed for developers'
do
before
do
@branch
=
create
:protected_branch
,
:developers_can_merge
,
project:
project
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment