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
Jérome Perrin
gitlab-ce
Commits
f3cfd209
Commit
f3cfd209
authored
Nov 18, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up code
parent
da7d4f84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
30 deletions
+24
-30
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+24
-30
No files found.
app/controllers/projects/blob_controller.rb
View file @
f3cfd209
...
...
@@ -23,21 +23,9 @@ class Projects::BlobController < Projects::ApplicationController
end
def
create
result
=
Files
::
CreateService
.
new
(
@project
,
current_user
,
@commit_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"The changes have been successfully committed"
respond_to
do
|
format
|
format
.
html
{
redirect_to
after_create_path
}
format
.
json
{
render
json:
{
message:
"success"
,
filePath:
after_create_path
}
}
end
else
flash
[
:alert
]
=
result
[
:message
]
respond_to
do
|
format
|
format
.
html
{
render
:new
}
format
.
json
{
render
json:
{
message:
"failed"
,
filePath:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
@id
)
}
}
end
end
create_commit
(
Files
::
CreateService
,
success_path:
after_create_path
,
failure_view: :new
,
failure_path:
namespace_project_new_blob_path
(
@project
.
namespace
,
@project
,
@ref
))
end
def
show
...
...
@@ -48,21 +36,9 @@ class Projects::BlobController < Projects::ApplicationController
end
def
update
result
=
Files
::
UpdateService
.
new
(
@project
,
current_user
,
@commit_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
respond_to
do
|
format
|
format
.
html
{
redirect_to
after_edit_path
}
format
.
json
{
render
json:
{
message:
"success"
,
filePath:
after_edit_path
}
}
end
else
flash
[
:alert
]
=
result
[
:message
]
respond_to
do
|
format
|
format
.
html
{
render
:edit
}
format
.
json
{
render
json:
{
message:
"failed"
,
filePath:
namespace_project_new_blob_path
(
@project
.
namespace
,
@project
,
@id
)
}
}
end
end
create_commit
(
Files
::
UpdateService
,
success_path:
after_edit_path
,
failure_view: :edit
,
failure_path:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
@id
))
end
def
preview
...
...
@@ -132,6 +108,24 @@ class Projects::BlobController < Projects::ApplicationController
render_404
end
def
create_commit
(
service
,
success_path
:,
failure_view
:,
failure_path
:)
result
=
service
.
new
(
@project
,
current_user
,
@commit_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
respond_to
do
|
format
|
format
.
html
{
redirect_to
success_path
}
format
.
json
{
render
json:
{
message:
"success"
,
filePath:
success_path
}
}
end
else
flash
[
:alert
]
=
result
[
:message
]
respond_to
do
|
format
|
format
.
html
{
render
failure_view
}
format
.
json
{
render
json:
{
message:
"failed"
,
filePath:
failure_path
}
}
end
end
end
def
after_create_path
@after_create_path
||=
if
create_merge_request?
...
...
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