Skip to content
Snippets Groups Projects
Commit 7fa80b5b authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Update branch api not found messages to 'Branch not found'.

parent 0991d19c
No related branches found
No related tags found
No related merge requests found
Loading
@@ -14,7 +14,8 @@ module API
Loading
@@ -14,7 +14,8 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/repository/branches # GET /projects/:id/repository/branches
get ":id/repository/branches" do get ":id/repository/branches" do
present user_project.repository.branches.sort_by(&:name), with: Entities::RepoObject, project: user_project branches = user_project.repository.branches.sort_by(&:name)
present branches, with: Entities::RepoObject, project: user_project
end end
   
# Get a single branch # Get a single branch
Loading
@@ -26,7 +27,7 @@ module API
Loading
@@ -26,7 +27,7 @@ module API
# GET /projects/:id/repository/branches/:branch # GET /projects/:id/repository/branches/:branch
get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do
@branch = user_project.repository.branches.find { |item| item.name == params[:branch] } @branch = user_project.repository.branches.find { |item| item.name == params[:branch] }
not_found!("Branch does not exist") if @branch.nil? not_found!("Branch") unless @branch
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
end end
   
Loading
@@ -43,7 +44,7 @@ module API
Loading
@@ -43,7 +44,7 @@ module API
authorize_admin_project authorize_admin_project
   
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
not_found! unless @branch not_found!("Branch") unless @branch
protected_branch = user_project.protected_branches.find_by(name: @branch.name) protected_branch = user_project.protected_branches.find_by(name: @branch.name)
user_project.protected_branches.create(name: @branch.name) unless protected_branch user_project.protected_branches.create(name: @branch.name) unless protected_branch
   
Loading
@@ -63,7 +64,7 @@ module API
Loading
@@ -63,7 +64,7 @@ module API
authorize_admin_project authorize_admin_project
   
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
not_found! unless @branch not_found!("Branch does not exist") unless @branch
protected_branch = user_project.protected_branches.find_by(name: @branch.name) protected_branch = user_project.protected_branches.find_by(name: @branch.name)
protected_branch.destroy if protected_branch protected_branch.destroy if protected_branch
   
Loading
Loading
Loading
@@ -42,7 +42,7 @@ module API
Loading
@@ -42,7 +42,7 @@ module API
   
def user_project def user_project
@project ||= find_project(params[:id]) @project ||= find_project(params[:id])
@project || not_found! @project || not_found!("Project")
end end
   
def find_project(id) def find_project(id)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment