diff options
author | Robert Speicher <robert@gitlab.com> | 2018-09-01 00:39:43 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-09-01 00:39:43 +0000 |
commit | 21b7e203b3d0b3048cd5f860e602d8a18655f118 (patch) | |
tree | 508e57775ff761599b25ca499daa15551e33c85e | |
parent | f9b96bd273c636c41e0160b97ea9182f97339f26 (diff) | |
parent | 5e5a16a5a8777f6de466f1e790a53a8a1c5b53d7 (diff) | |
download | gitlab-ce-21b7e203b3d0b3048cd5f860e602d8a18655f118.tar.gz |
Merge branch 'feature/#32877-add-default-field-branch-api' into 'master'
Add default parameter to branches API
Closes #32877
See merge request gitlab-org/gitlab-ce!21294
-rw-r--r-- | changelogs/unreleased/feature--32877-add-default-field-branch-api.yml | 5 | ||||
-rw-r--r-- | doc/api/branches.md | 5 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/public_api/v4/branch.json | 2 |
4 files changed, 16 insertions, 0 deletions
diff --git a/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml b/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml new file mode 100644 index 00000000000..a99ecc9a67e --- /dev/null +++ b/changelogs/unreleased/feature--32877-add-default-field-branch-api.yml @@ -0,0 +1,5 @@ +--- +title: Add default parameter to branches API +merge_request: 21294 +author: Riccardo Padovani +type: changed diff --git a/doc/api/branches.md b/doc/api/branches.md index bfb21608d28..4abf0639eb0 100644 --- a/doc/api/branches.md +++ b/doc/api/branches.md @@ -27,6 +27,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, @@ -75,6 +76,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true, @@ -141,6 +143,7 @@ Example response: "name": "master", "merged": false, "protected": true, + "default": true, "developers_can_push": true, "developers_can_merge": true, "can_push": true @@ -190,6 +193,7 @@ Example response: "name": "master", "merged": false, "protected": false, + "default": true, "developers_can_push": false, "developers_can_merge": false, "can_push": true @@ -234,6 +238,7 @@ Example response: "name": "newbranch", "merged": false, "protected": false, + "default": false, "developers_can_push": false, "developers_can_merge": false, "can_push": true diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 95b25d7351a..59042d2b568 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -370,6 +370,10 @@ module API expose :can_push do |repo_branch, options| Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name) end + + expose :default do |repo_branch, options| + options[:project].default_branch == repo_branch.name + end end class TreeObject < Grape::Entity diff --git a/spec/fixtures/api/schemas/public_api/v4/branch.json b/spec/fixtures/api/schemas/public_api/v4/branch.json index a8891680d06..3b0f010bc4f 100644 --- a/spec/fixtures/api/schemas/public_api/v4/branch.json +++ b/spec/fixtures/api/schemas/public_api/v4/branch.json @@ -5,6 +5,7 @@ "commit", "merged", "protected", + "default", "developers_can_push", "developers_can_merge" ], @@ -13,6 +14,7 @@ "commit": { "$ref": "commit/basic.json" }, "merged": { "type": "boolean" }, "protected": { "type": "boolean" }, + "default": { "type": "boolean" }, "developers_can_push": { "type": "boolean" }, "developers_can_merge": { "type": "boolean" }, "can_push": { "type": "boolean" } |