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
eafe834c
Commit
eafe834c
authored
Feb 06, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce remaining diff with EE in app/services
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ed7144ad
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
62 additions
and
35 deletions
+62
-35
app/services/applications/create_service.rb
app/services/applications/create_service.rb
+4
-4
app/services/concerns/exclusive_lease_guard.rb
app/services/concerns/exclusive_lease_guard.rb
+1
-1
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+2
-2
app/services/emails/base_service.rb
app/services/emails/base_service.rb
+3
-2
app/services/emails/create_service.rb
app/services/emails/create_service.rb
+4
-5
app/services/git_push_service.rb
app/services/git_push_service.rb
+7
-1
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+5
-1
app/services/issues/build_service.rb
app/services/issues/build_service.rb
+7
-1
app/services/notes/quick_actions_service.rb
app/services/notes/quick_actions_service.rb
+6
-1
app/services/notification_recipient_service.rb
app/services/notification_recipient_service.rb
+6
-1
app/services/protected_branches/api_service.rb
app/services/protected_branches/api_service.rb
+6
-7
app/services/protected_branches/legacy_api_update_service.rb
app/services/protected_branches/legacy_api_update_service.rb
+10
-9
lib/tasks/dev.rake
lib/tasks/dev.rake
+1
-0
No files found.
app/services/applications/create_service.rb
View file @
eafe834c
...
@@ -2,16 +2,16 @@
...
@@ -2,16 +2,16 @@
module
Applications
module
Applications
class
CreateService
class
CreateService
# rubocop: disable CodeReuse/ActiveRecord
attr_reader
:current_user
,
:params
def
initialize
(
current_user
,
params
)
def
initialize
(
current_user
,
params
)
@current_user
=
current_user
@current_user
=
current_user
@params
=
params
.
except
(
:ip_address
)
@params
=
params
.
except
(
:ip_address
)
# rubocop: disable CodeReuse/ActiveRecord
end
end
# rubocop: enable CodeReuse/ActiveRecord
# EE would override and use `request` arg
# EE would override and use `request` arg
def
execute
(
request
)
def
execute
(
request
)
Doorkeeper
::
Application
.
create
(
@
params
)
Doorkeeper
::
Application
.
create
(
params
)
end
end
end
end
end
end
app/services/concerns/exclusive_lease_guard.rb
View file @
eafe834c
...
@@ -42,7 +42,7 @@ module ExclusiveLeaseGuard
...
@@ -42,7 +42,7 @@ module ExclusiveLeaseGuard
def
lease_timeout
def
lease_timeout
raise
NotImplementedError
,
raise
NotImplementedError
,
"
#{
self
.
class
.
name
}
does not implement
#{
__method__
}
"
"
#{
self
.
class
.
name
}
does not implement
#{
__method__
}
"
end
end
def
lease_release?
def
lease_release?
...
...
app/services/create_branch_service.rb
View file @
eafe834c
# frozen_string_literal: true
# frozen_string_literal: true
class
CreateBranchService
<
BaseService
class
CreateBranchService
<
BaseService
def
execute
(
branch_name
,
ref
)
def
execute
(
branch_name
,
ref
,
create_master_if_empty:
true
)
create_master_branch
if
project
.
empty_repo?
create_master_branch
if
create_master_if_empty
&&
project
.
empty_repo?
result
=
ValidateNewBranchService
.
new
(
project
,
current_user
)
result
=
ValidateNewBranchService
.
new
(
project
,
current_user
)
.
execute
(
branch_name
)
.
execute
(
branch_name
)
...
...
app/services/emails/base_service.rb
View file @
eafe834c
...
@@ -2,10 +2,11 @@
...
@@ -2,10 +2,11 @@
module
Emails
module
Emails
class
BaseService
class
BaseService
attr_reader
:current_user
attr_reader
:current_user
,
:params
,
:user
def
initialize
(
current_user
,
params
=
{})
def
initialize
(
current_user
,
params
=
{})
@current_user
,
@params
=
current_user
,
params
.
dup
@current_user
=
current_user
@params
=
params
.
dup
@user
=
params
.
delete
(
:user
)
@user
=
params
.
delete
(
:user
)
end
end
end
end
...
...
app/services/emails/create_service.rb
View file @
eafe834c
...
@@ -3,12 +3,11 @@
...
@@ -3,12 +3,11 @@
module
Emails
module
Emails
class
CreateService
<
::
Emails
::
BaseService
class
CreateService
<
::
Emails
::
BaseService
def
execute
(
extra_params
=
{})
def
execute
(
extra_params
=
{})
skip_confirmation
=
@
params
.
delete
(
:skip_confirmation
)
skip_confirmation
=
params
.
delete
(
:skip_confirmation
)
email
=
@user
.
emails
.
create
(
@params
.
merge
(
extra_params
))
user
.
emails
.
create
(
params
.
merge
(
extra_params
)).
tap
do
|
email
|
email
&
.
confirm
if
skip_confirmation
&&
current_user
.
admin?
email
&
.
confirm
if
skip_confirmation
&&
current_user
.
admin?
end
email
end
end
end
end
end
end
app/services/git_push_service.rb
View file @
eafe834c
...
@@ -140,7 +140,7 @@ class GitPushService < BaseService
...
@@ -140,7 +140,7 @@ class GitPushService < BaseService
.
perform_async
(
project
.
id
,
current_user
.
id
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
])
.
perform_async
(
project
.
id
,
current_user
.
id
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
])
EventCreateService
.
new
.
push
(
project
,
current_user
,
build_push_data
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
build_push_data
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
build_push_data
).
execute
(
:push
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
build_push_data
).
execute
(
:push
,
pipeline_options
)
project
.
execute_hooks
(
build_push_data
.
dup
,
:push_hooks
)
project
.
execute_hooks
(
build_push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
build_push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
build_push_data
.
dup
,
:push_hooks
)
...
@@ -231,4 +231,10 @@ class GitPushService < BaseService
...
@@ -231,4 +231,10 @@ class GitPushService < BaseService
def
last_pushed_commits
def
last_pushed_commits
@last_pushed_commits
||=
@push_commits
.
last
(
PROCESS_COMMIT_LIMIT
)
@last_pushed_commits
||=
@push_commits
.
last
(
PROCESS_COMMIT_LIMIT
)
end
end
private
def
pipeline_options
{}
# to be overriden in EE
end
end
end
app/services/git_tag_push_service.rb
View file @
eafe834c
...
@@ -10,7 +10,7 @@ class GitTagPushService < BaseService
...
@@ -10,7 +10,7 @@ class GitTagPushService < BaseService
@push_data
=
build_push_data
@push_data
=
build_push_data
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
push_data
).
execute
(
:push
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
push_data
).
execute
(
:push
,
pipeline_options
)
SystemHooksService
.
new
.
execute_hooks
(
build_system_push_data
,
:tag_push_hooks
)
SystemHooksService
.
new
.
execute_hooks
(
build_system_push_data
,
:tag_push_hooks
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
...
@@ -59,4 +59,8 @@ class GitTagPushService < BaseService
...
@@ -59,4 +59,8 @@ class GitTagPushService < BaseService
[],
[],
''
)
''
)
end
end
def
pipeline_options
{}
# to be overriden in EE
end
end
end
app/services/issues/build_service.rb
View file @
eafe834c
...
@@ -57,9 +57,11 @@ module Issues
...
@@ -57,9 +57,11 @@ module Issues
end
end
def
issue_params
def
issue_params
@issue_params
||=
issue_params_with_info_from_discussions
.
merge
(
whitelisted_issue_params
)
@issue_params
||=
build_issue_params
end
end
private
def
whitelisted_issue_params
def
whitelisted_issue_params
if
can?
(
current_user
,
:admin_issue
,
project
)
if
can?
(
current_user
,
:admin_issue
,
project
)
params
.
slice
(
:title
,
:description
,
:milestone_id
)
params
.
slice
(
:title
,
:description
,
:milestone_id
)
...
@@ -67,5 +69,9 @@ module Issues
...
@@ -67,5 +69,9 @@ module Issues
params
.
slice
(
:title
,
:description
)
params
.
slice
(
:title
,
:description
)
end
end
end
end
def
build_issue_params
issue_params_with_info_from_discussions
.
merge
(
whitelisted_issue_params
)
end
end
end
end
end
app/services/notes/quick_actions_service.rb
View file @
eafe834c
...
@@ -7,9 +7,14 @@ module Notes
...
@@ -7,9 +7,14 @@ module Notes
'MergeRequest'
=>
MergeRequests
::
UpdateService
,
'MergeRequest'
=>
MergeRequests
::
UpdateService
,
'Commit'
=>
Commits
::
TagService
'Commit'
=>
Commits
::
TagService
}.
freeze
}.
freeze
private_constant
:UPDATE_SERVICES
def
self
.
update_services
UPDATE_SERVICES
end
def
self
.
noteable_update_service
(
note
)
def
self
.
noteable_update_service
(
note
)
UPDATE_SERVICES
[
note
.
noteable_type
]
update_services
[
note
.
noteable_type
]
end
end
def
self
.
supported?
(
note
)
def
self
.
supported?
(
note
)
...
...
app/services/notification_recipient_service.rb
View file @
eafe834c
...
@@ -249,6 +249,7 @@ module NotificationRecipientService
...
@@ -249,6 +249,7 @@ module NotificationRecipientService
attr_reader
:action
attr_reader
:action
attr_reader
:previous_assignee
attr_reader
:previous_assignee
attr_reader
:skip_current_user
attr_reader
:skip_current_user
def
initialize
(
target
,
current_user
,
action
:,
custom_action:
nil
,
previous_assignee:
nil
,
skip_current_user:
true
)
def
initialize
(
target
,
current_user
,
action
:,
custom_action:
nil
,
previous_assignee:
nil
,
skip_current_user:
true
)
@target
=
target
@target
=
target
@current_user
=
current_user
@current_user
=
current_user
...
@@ -258,9 +259,13 @@ module NotificationRecipientService
...
@@ -258,9 +259,13 @@ module NotificationRecipientService
@skip_current_user
=
skip_current_user
@skip_current_user
=
skip_current_user
end
end
def
add_watchers
add_project_watchers
end
def
build!
def
build!
add_participants
(
current_user
)
add_participants
(
current_user
)
add_
project_
watchers
add_watchers
add_custom_notifications
add_custom_notifications
# Re-assign is considered as a mention of the new assignee
# Re-assign is considered as a mention of the new assignee
...
...
app/services/protected_branches/api_service.rb
View file @
eafe834c
...
@@ -3,16 +3,15 @@
...
@@ -3,16 +3,15 @@
module
ProtectedBranches
module
ProtectedBranches
class
ApiService
<
BaseService
class
ApiService
<
BaseService
def
create
def
create
@push_params
=
AccessLevelParams
.
new
(
:push
,
params
)
::
ProtectedBranches
::
CreateService
.
new
(
@project
,
@current_user
,
protected_branch_params
).
execute
@merge_params
=
AccessLevelParams
.
new
(
:merge
,
params
)
end
protected_branch_params
=
{
def
protected_branch_params
{
name:
params
[
:name
],
name:
params
[
:name
],
push_access_levels_attributes:
@push_params
.
access_levels
,
push_access_levels_attributes:
AccessLevelParams
.
new
(
:push
,
params
)
.
access_levels
,
merge_access_levels_attributes:
@merge_params
.
access_levels
merge_access_levels_attributes:
AccessLevelParams
.
new
(
:merge
,
params
)
.
access_levels
}
}
::
ProtectedBranches
::
CreateService
.
new
(
@project
,
@current_user
,
protected_branch_params
).
execute
end
end
end
end
end
end
app/services/protected_branches/legacy_api_update_service.rb
View file @
eafe834c
...
@@ -6,30 +6,31 @@
...
@@ -6,30 +6,31 @@
# lives in this service.
# lives in this service.
module
ProtectedBranches
module
ProtectedBranches
class
LegacyApiUpdateService
<
BaseService
class
LegacyApiUpdateService
<
BaseService
attr_reader
:protected_branch
,
:developers_can_push
,
:developers_can_merge
def
execute
(
protected_branch
)
def
execute
(
protected_branch
)
@protected_branch
=
protected_branch
@developers_can_push
=
params
.
delete
(
:developers_can_push
)
@developers_can_push
=
params
.
delete
(
:developers_can_push
)
@developers_can_merge
=
params
.
delete
(
:developers_can_merge
)
@developers_can_merge
=
params
.
delete
(
:developers_can_merge
)
@protected_branch
=
protected_branch
protected_branch
.
transaction
do
protected_branch
.
transaction
do
delete_redundant_access_levels
delete_redundant_access_levels
case
@
developers_can_push
case
developers_can_push
when
true
when
true
params
[
:push_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}]
params
[
:push_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}]
when
false
when
false
params
[
:push_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
MAINTAINER
}]
params
[
:push_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
MAINTAINER
}]
end
end
case
@
developers_can_merge
case
developers_can_merge
when
true
when
true
params
[
:merge_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}]
params
[
:merge_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
DEVELOPER
}]
when
false
when
false
params
[
:merge_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
MAINTAINER
}]
params
[
:merge_access_levels_attributes
]
=
[{
access_level:
Gitlab
::
Access
::
MAINTAINER
}]
end
end
service
=
ProtectedBranches
::
UpdateService
.
new
(
@project
,
@current_user
,
@
params
)
service
=
ProtectedBranches
::
UpdateService
.
new
(
project
,
current_user
,
params
)
service
.
execute
(
protected_branch
)
service
.
execute
(
protected_branch
)
end
end
end
end
...
@@ -37,12 +38,12 @@ module ProtectedBranches
...
@@ -37,12 +38,12 @@ module ProtectedBranches
private
private
def
delete_redundant_access_levels
def
delete_redundant_access_levels
unless
@
developers_can_merge
.
nil?
unless
developers_can_merge
.
nil?
@
protected_branch
.
merge_access_levels
.
destroy_all
# rubocop: disable DestroyAll
protected_branch
.
merge_access_levels
.
destroy_all
# rubocop: disable DestroyAll
end
end
unless
@
developers_can_push
.
nil?
unless
developers_can_push
.
nil?
@
protected_branch
.
push_access_levels
.
destroy_all
# rubocop: disable DestroyAll
protected_branch
.
push_access_levels
.
destroy_all
# rubocop: disable DestroyAll
end
end
end
end
end
end
...
...
lib/tasks/dev.rake
View file @
eafe834c
...
@@ -10,6 +10,7 @@ namespace :dev do
...
@@ -10,6 +10,7 @@ namespace :dev do
desc
"GitLab | Eager load application"
desc
"GitLab | Eager load application"
task
load: :environment
do
task
load: :environment
do
Rails
.
configuration
.
eager_load
=
true
Rails
.
application
.
eager_load!
Rails
.
application
.
eager_load!
end
end
end
end
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