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
3baed8cb
Commit
3baed8cb
authored
Jul 06, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Services: code style fixes, minor refactoring
parent
cfd5870b
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
37 additions
and
43 deletions
+37
-43
app/services/audit_event_service.rb
app/services/audit_event_service.rb
+1
-1
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+2
-0
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+5
-5
app/services/create_release_service.rb
app/services/create_release_service.rb
+1
-3
app/services/create_snippet_service.rb
app/services/create_snippet_service.rb
+5
-5
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+2
-0
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+2
-10
app/services/delete_tag_service.rb
app/services/delete_tag_service.rb
+2
-7
app/services/files/base_service.rb
app/services/files/base_service.rb
+3
-4
app/services/files/create_service.rb
app/services/files/create_service.rb
+1
-1
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+1
-0
app/services/issues/bulk_update_service.rb
app/services/issues/bulk_update_service.rb
+1
-0
app/services/merge_requests/post_merge_service.rb
app/services/merge_requests/post_merge_service.rb
+1
-0
app/services/notification_service.rb
app/services/notification_service.rb
+2
-0
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+2
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+4
-3
app/services/update_release_service.rb
app/services/update_release_service.rb
+1
-3
app/services/update_snippet_service.rb
app/services/update_snippet_service.rb
+1
-0
No files found.
app/services/audit_event_service.rb
View file @
3baed8cb
...
...
@@ -7,7 +7,7 @@ class AuditEventService
@details
=
{
with:
@details
[
:with
],
target_id:
@author
.
id
,
target_type:
"User"
,
target_type:
'User'
,
target_details:
@author
.
name
,
}
...
...
app/services/auth/container_registry_authentication_service.rb
View file @
3baed8cb
...
...
@@ -20,9 +20,11 @@ module Auth
token
.
issuer
=
registry
.
issuer
token
.
audience
=
AUDIENCE
token
.
expire_time
=
token_expire_at
token
[
:access
]
=
names
.
map
do
|
name
|
{
type:
'repository'
,
name:
name
,
actions:
%w(*)
}
end
token
.
encoded
end
...
...
app/services/create_branch_service.rb
View file @
3baed8cb
...
...
@@ -3,17 +3,20 @@ require_relative 'base_service'
class
CreateBranchService
<
BaseService
def
execute
(
branch_name
,
ref
,
source_project:
@project
)
valid_branch
=
Gitlab
::
GitRefValidator
.
validate
(
branch_name
)
if
valid_branch
==
false
unless
valid_branch
return
error
(
'Branch name is invalid'
)
end
repository
=
project
.
repository
existing_branch
=
repository
.
find_branch
(
branch_name
)
if
existing_branch
return
error
(
'Branch already exists'
)
end
new_branch
=
nil
if
source_project
!=
@project
repository
.
with_tmp_ref
do
|
tmp_ref
|
repository
.
fetch_ref
(
...
...
@@ -29,7 +32,6 @@ class CreateBranchService < BaseService
end
if
new_branch
# GitPushService handles execution of services and hooks for branch pushes
success
(
new_branch
)
else
error
(
'Invalid reference name'
)
...
...
@@ -39,8 +41,6 @@ class CreateBranchService < BaseService
end
def
success
(
branch
)
out
=
super
()
out
[
:branch
]
=
branch
out
super
().
merge
(
branch:
branch
)
end
end
app/services/create_release_service.rb
View file @
3baed8cb
...
...
@@ -23,8 +23,6 @@ class CreateReleaseService < BaseService
end
def
success
(
release
)
out
=
super
()
out
[
:release
]
=
release
out
super
().
merge
(
release:
release
)
end
end
app/services/create_snippet_service.rb
View file @
3baed8cb
class
CreateSnippetService
<
BaseService
def
execute
if
project
.
nil?
snippet
=
PersonalSnippet
.
new
(
params
)
snippet
=
if
project
project
.
snippets
.
build
(
params
)
else
snippet
=
project
.
snippets
.
build
(
params
)
PersonalSnippet
.
new
(
params
)
end
unless
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
params
[
:visibility_level
])
...
...
app/services/create_tag_service.rb
View file @
3baed8cb
...
...
@@ -9,6 +9,7 @@ class CreateTagService < BaseService
message
.
strip!
if
message
new_tag
=
nil
begin
new_tag
=
repository
.
add_tag
(
current_user
,
tag_name
,
target
,
message
)
rescue
Rugged
::
TagError
...
...
@@ -22,6 +23,7 @@ class CreateTagService < BaseService
CreateReleaseService
.
new
(
@project
,
@current_user
).
execute
(
tag_name
,
release_description
)
end
success
.
merge
(
tag:
new_tag
)
else
error
(
"Target
#{
target
}
is invalid"
)
...
...
app/services/delete_branch_service.rb
View file @
3baed8cb
...
...
@@ -5,7 +5,6 @@ class DeleteBranchService < BaseService
repository
=
project
.
repository
branch
=
repository
.
find_branch
(
branch_name
)
# No such branch
unless
branch
return
error
(
'No such branch'
,
404
)
end
...
...
@@ -14,18 +13,15 @@ class DeleteBranchService < BaseService
return
error
(
'Cannot remove HEAD branch'
,
405
)
end
# Dont allow remove of protected branch
if
project
.
protected_branch?
(
branch_name
)
return
error
(
'Protected branch cant be removed'
,
405
)
end
# Dont allow user to remove branch if he is not allowed to push
unless
current_user
.
can?
(
:push_code
,
project
)
return
error
(
'You dont have push access to repo'
,
405
)
end
if
repository
.
rm_branch
(
current_user
,
branch_name
)
# GitPushService handles execution of services and hooks for branch pushes
success
(
'Branch was removed'
)
else
error
(
'Failed to remove branch'
)
...
...
@@ -35,15 +31,11 @@ class DeleteBranchService < BaseService
end
def
error
(
message
,
return_code
=
400
)
out
=
super
(
message
)
out
[
:return_code
]
=
return_code
out
super
(
message
).
merge
(
return_code:
return_code
)
end
def
success
(
message
)
out
=
super
()
out
[
:message
]
=
message
out
super
().
merge
(
message:
message
)
end
def
build_push_data
(
branch
)
...
...
app/services/delete_tag_service.rb
View file @
3baed8cb
...
...
@@ -5,7 +5,6 @@ class DeleteTagService < BaseService
repository
=
project
.
repository
tag
=
repository
.
find_tag
(
tag_name
)
# No such tag
unless
tag
return
error
(
'No such tag'
,
404
)
end
...
...
@@ -26,15 +25,11 @@ class DeleteTagService < BaseService
end
def
error
(
message
,
return_code
=
400
)
out
=
super
(
message
)
out
[
:return_code
]
=
return_code
out
super
(
message
).
merge
(
return_code:
return_code
)
end
def
success
(
message
)
out
=
super
()
out
[
:message
]
=
message
out
super
().
merge
(
message:
message
)
end
def
build_push_data
(
tag
)
...
...
app/services/files/base_service.rb
View file @
3baed8cb
...
...
@@ -15,7 +15,6 @@ module Files
params
[
:file_content
]
end
# Validate parameters
validate
# Create new branch if it different from source_branch
...
...
@@ -26,7 +25,7 @@ module Files
if
commit
success
else
error
(
"Something went wrong. Your changes were not committed"
)
error
(
'Something went wrong. Your changes were not committed'
)
end
rescue
Repository
::
CommitError
,
Gitlab
::
Git
::
Repository
::
InvalidBlobName
,
GitHooksService
::
PreReceiveError
,
ValidationError
=>
ex
error
(
ex
.
message
)
...
...
@@ -51,12 +50,12 @@ module Files
unless
project
.
empty_repo?
unless
@source_project
.
repository
.
branch_names
.
include?
(
@source_branch
)
raise_error
(
"You can only create or edit files when you are on a branch"
)
raise_error
(
'You can only create or edit files when you are on a branch'
)
end
if
different_branch?
if
repository
.
branch_names
.
include?
(
@target_branch
)
raise_error
(
"Branch with such name already exists. You need to switch to this branch in order to make changes"
)
raise_error
(
'Branch with such name already exists. You need to switch to this branch in order to make changes'
)
end
end
end
...
...
app/services/files/create_service.rb
View file @
3baed8cb
...
...
@@ -29,7 +29,7 @@ module Files
blob
=
repository
.
blob_at_branch
(
@source_branch
,
@file_path
)
if
blob
raise_error
(
"Your changes could not be committed because a file with the same name already exists"
)
raise_error
(
'Your changes could not be committed because a file with the same name already exists'
)
end
end
end
...
...
app/services/git_tag_push_service.rb
View file @
3baed8cb
...
...
@@ -26,6 +26,7 @@ class GitTagPushService < BaseService
unless
Gitlab
::
Git
.
blank_ref?
(
params
[
:newrev
])
tag_name
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
tag
=
project
.
repository
.
find_tag
(
tag_name
)
if
tag
&&
tag
.
target
==
params
[
:newrev
]
commit
=
project
.
commit
(
tag
.
target
)
commits
=
[
commit
].
compact
...
...
app/services/issues/bulk_update_service.rb
View file @
3baed8cb
...
...
@@ -9,6 +9,7 @@ module Issues
end
issues
=
Issue
.
where
(
id:
issues_ids
)
issues
.
each
do
|
issue
|
next
unless
can?
(
current_user
,
:update_issue
,
issue
)
...
...
app/services/merge_requests/post_merge_service.rb
View file @
3baed8cb
...
...
@@ -20,6 +20,7 @@ module MergeRequests
return
unless
merge_request
.
target_branch
==
project
.
default_branch
closed_issues
=
merge_request
.
closes_issues
(
current_user
)
closed_issues
.
each
do
|
issue
|
if
can?
(
current_user
,
:update_issue
,
issue
)
Issues
::
CloseService
.
new
(
project
,
current_user
,
{}).
execute
(
issue
,
commit:
merge_request
)
...
...
app/services/notification_service.rb
View file @
3baed8cb
...
...
@@ -153,6 +153,7 @@ class NotificationService
else
mentioned_users
end
recipients
=
recipients
.
concat
(
participants
)
# Merge project watchers
...
...
@@ -176,6 +177,7 @@ class NotificationService
# build notify method like 'note_commit_email'
notify_method
=
"note_
#{
note
.
noteable_type
.
underscore
}
_email"
.
to_sym
recipients
.
each
do
|
recipient
|
mailer
.
send
(
notify_method
,
recipient
.
id
,
note
.
id
).
deliver_later
end
...
...
app/services/projects/update_service.rb
View file @
3baed8cb
...
...
@@ -3,6 +3,7 @@ module Projects
def
execute
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
project
.
visibility_level
unless
can?
(
current_user
,
:change_visibility_level
,
project
)
&&
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
...
...
app/services/system_note_service.rb
View file @
3baed8cb
...
...
@@ -82,7 +82,7 @@ class SystemNoteService
end
body
<<
' '
<<
'label'
.
pluralize
(
labels_count
)
body
=
"
#{
body
.
capitalize
}
"
body
=
body
.
capitalize
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -125,7 +125,7 @@ class SystemNoteService
# Returns the created Note object
def
self
.
change_status
(
noteable
,
project
,
author
,
status
,
source
)
body
=
"Status changed to
#{
status
}
"
body
+=
" by
#{
source
.
gfm_reference
(
project
)
}
"
if
source
body
<<
" by
#{
source
.
gfm_reference
(
project
)
}
"
if
source
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -139,7 +139,7 @@ class SystemNoteService
# Called when 'merge when build succeeds' is canceled
def
self
.
cancel_merge_when_build_succeeds
(
noteable
,
project
,
author
)
body
=
"Canceled the automatic merge"
body
=
'Canceled the automatic merge'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -236,6 +236,7 @@ class SystemNoteService
else
'deleted'
end
body
=
"
#{
verb
}
#{
branch_type
.
to_s
}
branch `
#{
branch
}
`"
.
capitalize
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
app/services/update_release_service.rb
View file @
3baed8cb
...
...
@@ -21,8 +21,6 @@ class UpdateReleaseService < BaseService
end
def
success
(
release
)
out
=
super
()
out
[
:release
]
=
release
out
super
().
merge
(
release:
release
)
end
end
app/services/update_snippet_service.rb
View file @
3baed8cb
...
...
@@ -9,6 +9,7 @@ class UpdateSnippetService < BaseService
def
execute
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
snippet
.
visibility_level
unless
Gitlab
::
VisibilityLevel
.
allowed_for?
(
current_user
,
new_visibility
)
deny_visibility_level
(
snippet
,
new_visibility
)
...
...
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