diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-16 21:15:05 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-16 21:15:16 -0300 |
commit | 3f111741967a5dcb6e0418471d2b26ca9ab04eac (patch) | |
tree | b32a7cc72b9ffaec3739e42821265401cee8a449 /lib/api/v3 | |
parent | 0fa511fdeb5e1089dbd82435cb1397b0d433b00b (diff) | |
download | gitlab-ce-3f111741967a5dcb6e0418471d2b26ca9ab04eac.tar.gz |
Use "branch_name" instead "branch" on V3 branch creation API29604-v3-fix-branch-creation
Diffstat (limited to 'lib/api/v3')
-rw-r--r-- | lib/api/v3/branches.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/v3/branches.rb b/lib/api/v3/branches.rb index 7d9d6246e46..0a877b960f6 100644 --- a/lib/api/v3/branches.rb +++ b/lib/api/v3/branches.rb @@ -45,6 +45,27 @@ module API status(200) end + + desc 'Create branch' do + success ::API::Entities::RepoBranch + end + params do + requires :branch_name, type: String, desc: 'The name of the branch' + requires :ref, type: String, desc: 'Create branch from commit sha or existing branch' + end + post ":id/repository/branches" do + authorize_push_project + result = CreateBranchService.new(user_project, current_user). + execute(params[:branch_name], params[:ref]) + + if result[:status] == :success + present result[:branch], + with: ::API::Entities::RepoBranch, + project: user_project + else + render_api_error!(result[:message], 400) + end + end end end end |