summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-22 21:00:11 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-22 21:00:11 +0300
commitdb12e2dc8d70536af1a886162cb19705d458f560 (patch)
tree27f3e2014a6bf2fdd31a639a639b07ae924eec07 /lib
parented9a6bf99c1abf261147956ec613211419b63ea5 (diff)
parentad47993ac46cef672600f2384ee5fa2e661ec8be (diff)
downloadgitlab-ce-db12e2dc8d70536af1a886162cb19705d458f560.tar.gz
Merge pull request #7807 from cirosantilli/factor-service-error
Factor error and success methods from services.
Diffstat (limited to 'lib')
-rw-r--r--lib/api/branches.rb11
-rw-r--r--lib/api/repositories.rb5
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 4db5f61dd28..75783628e3d 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -80,10 +80,8 @@ module API
# POST /projects/:id/repository/branches
post ":id/repository/branches" do
authorize_push_project
- result = CreateBranchService.new.execute(user_project,
- params[:branch_name],
- params[:ref],
- current_user)
+ result = CreateBranchService.new(user_project, current_user).
+ execute(params[:branch_name], params[:ref])
if result[:status] == :success
present result[:branch],
with: Entities::RepoObject,
@@ -102,9 +100,10 @@ module API
# DELETE /projects/:id/repository/branches/:branch
delete ":id/repository/branches/:branch" do
authorize_push_project
- result = DeleteBranchService.new.execute(user_project, params[:branch], current_user)
+ result = DeleteBranchService.new(user_project, current_user).
+ execute(params[:branch])
- if result[:state] == :success
+ if result[:status] == :success
true
else
render_api_error!(result[:message], result[:return_code])
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index 07c29aa7b4c..626d99c2649 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -38,9 +38,8 @@ module API
post ':id/repository/tags' do
authorize_push_project
message = params[:message] || nil
- result = CreateTagService.new.execute(user_project, params[:tag_name],
- params[:ref], message,
- current_user)
+ result = CreateTagService.new(user_project, current_user).
+ execute(params[:tag_name], params[:ref], message)
if result[:status] == :success
present result[:tag],