BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
protected_branch_access.rb
app/models/concerns/protected_branch_access.rb
+2
-2
api_create_service.rb
app/services/protected_branches/api_create_service.rb
+15
-10
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