summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-09-21 10:29:52 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2014-09-21 11:43:05 +0200
commitad47993ac46cef672600f2384ee5fa2e661ec8be (patch)
tree07769b4efeb4c18762b3ed0e705179a5423926c1 /lib/api
parentfda61a047ffb9b04bc4dd38e897088fde17fb3c1 (diff)
downloadgitlab-ce-ad47993ac46cef672600f2384ee5fa2e661ec8be.tar.gz
Factor error and success methods from services.
Diffstat (limited to 'lib/api')
-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],