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
Boxiang Sun
gitlab-ce
Commits
b803bc7b
Commit
b803bc7b
authored
Sep 22, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement review comments from @DouweM.
parent
cef10ef7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
app/models/concerns/protected_branch_access.rb
app/models/concerns/protected_branch_access.rb
+2
-2
app/services/protected_branches/api_create_service.rb
app/services/protected_branches/api_create_service.rb
+15
-10
lib/api/branches.rb
lib/api/branches.rb
+2
-2
No files found.
app/models/concerns/protected_branch_access.rb
View file @
b803bc7b
...
...
@@ -2,8 +2,8 @@ module ProtectedBranchAccess
extend
ActiveSupport
::
Concern
included
do
scope
:master
,
->
()
{
where
(
access_level:
Gitlab
::
Access
::
MASTER
)
}
scope
:developer
,
->
()
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
scope
:master
,
->
{
where
(
access_level:
Gitlab
::
Access
::
MASTER
)
}
scope
:developer
,
->
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
end
def
humanize
...
...
app/services/protected_branches/api_create_service.rb
View file @
b803bc7b
...
...
@@ -11,17 +11,22 @@ module ProtectedBranches
end
def
execute
if
@developers_can_push
@params
.
merge!
(
push_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}])
else
@params
.
merge!
(
push_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
MASTER
}])
end
push_access_level
=
if
@developers_can_push
Gitlab
::
Access
::
DEVELOPER
else
Gitlab
::
Access
::
MASTER
end
if
@developers_can_merge
@params
.
merge!
(
merge_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}])
else
@params
.
merge!
(
merge_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
MASTER
}])
end
merge_access_level
=
if
@developers_can_merge
Gitlab
::
Access
::
DEVELOPER
else
Gitlab
::
Access
::
MASTER
end
@params
.
merge!
(
push_access_levels_attributes:
[{
access_level:
push_access_level
}],
merge_access_levels_attributes:
[{
access_level:
merge_access_level
}])
service
=
ProtectedBranches
::
CreateService
.
new
(
@project
,
@current_user
,
@params
)
service
.
execute
...
...
lib/api/branches.rb
View file @
b803bc7b
...
...
@@ -57,11 +57,11 @@ module API
developers_can_merge
=
to_boolean
(
params
[
:developers_can_merge
])
developers_can_push
=
to_boolean
(
params
[
:developers_can_push
])
params
=
{
p
rotected_branch_p
arams
=
{
name:
@branch
.
name
,
}
service_args
=
[
user_project
,
current_user
,
params
,
service_args
=
[
user_project
,
current_user
,
p
rotected_branch_p
arams
,
developers_can_push:
developers_can_push
,
developers_can_merge:
developers_can_merge
]
...
...
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