Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-04 16:52:42 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-04 16:52:42 +0400
commit9bb1d8fc8d2119ed46ac2e11ed9d295a61cf7a28 (patch)
tree51f60862e936de65c581f46bf4b641a2e7ad2cfa /lib/api
parent640a3c5c89cc2d20382f4c1045e4b0b05964176a (diff)
parent392113919adc75ba1537d89a0de8d0641e24d5b8 (diff)
Merge pull request #7382 from Razer6/git_ref_validation
Validate branch/tag-names and references WebUI, API
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/branches.rb16
-rw-r--r--lib/api/repositories.rb13
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index b32a4aa7bc2..4db5f61dd28 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -80,9 +80,17 @@ module API
# POST /projects/:id/repository/branches
post ":id/repository/branches" do
authorize_push_project
- @branch = CreateBranchService.new.execute(user_project, params[:branch_name], params[:ref], current_user)
-
- present @branch, with: Entities::RepoObject, project: user_project
+ result = CreateBranchService.new.execute(user_project,
+ params[:branch_name],
+ params[:ref],
+ current_user)
+ if result[:status] == :success
+ present result[:branch],
+ with: Entities::RepoObject,
+ project: user_project
+ else
+ render_api_error!(result[:message], 400)
+ end
end
# Delete branch
@@ -99,7 +107,7 @@ module API
if result[:state] == :success
true
else
- render_api_error!(result[:message], 405)
+ render_api_error!(result[:message], result[:return_code])
end
end
end
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index 42068bb343d..a3773d2c593 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -36,10 +36,15 @@ module API
# POST /projects/:id/repository/tags
post ':id/repository/tags' do
authorize_push_project
- @tag = CreateTagService.new.execute(user_project, params[:tag_name],
- params[:ref], current_user)
-
- present @tag, with: Entities::RepoObject, project: user_project
+ result = CreateTagService.new.execute(user_project, params[:tag_name],
+ params[:ref], current_user)
+ if result[:status] == :success
+ present result[:tag],
+ with: Entities::RepoObject,
+ project: user_project
+ else
+ render_api_error!(result[:message], 400)
+ end
end
# Get a project repository tree