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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0fa7c880
Commit
0fa7c880
authored
Jan 23, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Projects::CreateService#execute by extracting methods
parent
d69694e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+21
-13
No files found.
app/services/projects/create_service.rb
View file @
0fa7c880
...
...
@@ -23,20 +23,9 @@ module Projects
end
# Repository size limit comes as MB from the view
limit
=
params
.
delete
(
:repository_size_limit
)
@project
.
repository_size_limit
=
(
limit
.
to_i
.
megabytes
if
limit
.
present?
)
set_repository_size_limit_as_bytes
# Set project name from path
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
# if both name and path set - everything is ok
elsif
@project
.
path
.
present?
# Set project name from path
@project
.
name
=
@project
.
path
.
dup
elsif
@project
.
name
.
present?
# For compatibility - set path from name
# TODO: remove this in 8.0
@project
.
path
=
@project
.
name
.
dup
.
parameterize
end
set_project_name_from_path
# get namespace id
namespace_id
=
params
[
:namespace_id
]
...
...
@@ -155,5 +144,24 @@ module Projects
service
.
save!
end
end
def
set_repository_size_limit_as_bytes
limit
=
params
.
delete
(
:repository_size_limit
)
@project
.
repository_size_limit
=
(
limit
.
to_i
.
megabytes
if
limit
.
present?
)
end
def
set_project_name_from_path
# Set project name from path
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
# if both name and path set - everything is ok
elsif
@project
.
path
.
present?
# Set project name from path
@project
.
name
=
@project
.
path
.
dup
elsif
@project
.
name
.
present?
# For compatibility - set path from name
# TODO: remove this in 8.0
@project
.
path
=
@project
.
name
.
dup
.
parameterize
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