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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
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
+9
-4
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
...
@@ -2,8 +2,8 @@ module ProtectedBranchAccess
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
scope
:master
,
->
()
{
where
(
access_level:
Gitlab
::
Access
::
MASTER
)
}
scope
:master
,
->
{
where
(
access_level:
Gitlab
::
Access
::
MASTER
)
}
scope
:developer
,
->
()
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
scope
:developer
,
->
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
end
end
def
humanize
def
humanize
...
...
app/services/protected_branches/api_create_service.rb
View file @
b803bc7b
...
@@ -11,18 +11,23 @@ module ProtectedBranches
...
@@ -11,18 +11,23 @@ module ProtectedBranches
end
end
def
execute
def
execute
push_access_level
=
if
@developers_can_push
if
@developers_can_push
@params
.
merge!
(
push_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}])
Gitlab
::
Access
::
DEVELOPER
else
else
@params
.
merge!
(
push_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
MASTER
}])
Gitlab
::
Access
::
MASTER
end
end
merge_access_level
=
if
@developers_can_merge
if
@developers_can_merge
@params
.
merge!
(
merge_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}])
Gitlab
::
Access
::
DEVELOPER
else
else
@params
.
merge!
(
merge_access_levels_attributes:
[{
access_level:
Gitlab
::
Access
::
MASTER
}])
Gitlab
::
Access
::
MASTER
end
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
=
ProtectedBranches
::
CreateService
.
new
(
@project
,
@current_user
,
@params
)
service
.
execute
service
.
execute
end
end
...
...
lib/api/branches.rb
View file @
b803bc7b
...
@@ -57,11 +57,11 @@ module API
...
@@ -57,11 +57,11 @@ module API
developers_can_merge
=
to_boolean
(
params
[
:developers_can_merge
])
developers_can_merge
=
to_boolean
(
params
[
:developers_can_merge
])
developers_can_push
=
to_boolean
(
params
[
:developers_can_push
])
developers_can_push
=
to_boolean
(
params
[
:developers_can_push
])
params
=
{
p
rotected_branch_p
arams
=
{
name:
@branch
.
name
,
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_push:
developers_can_push
,
developers_can_merge:
developers_can_merge
]
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