summaryrefslogtreecommitdiff
path: root/lib/api/entities/branch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities/branch.rb')
-rw-r--r--lib/api/entities/branch.rb44
1 files changed, 36 insertions, 8 deletions
diff --git a/lib/api/entities/branch.rb b/lib/api/entities/branch.rb
index 6a75dcddeda..01eaf5c8d31 100644
--- a/lib/api/entities/branch.rb
+++ b/lib/api/entities/branch.rb
@@ -5,13 +5,17 @@ module API
class Branch < Grape::Entity
include Gitlab::Routing
- expose :name
+ expose :name, documentation: { type: 'string', example: 'master' }
expose :commit, using: Entities::Commit do |repo_branch, options|
options[:project].repository.commit(repo_branch.dereferenced_target)
end
- expose :merged do |repo_branch, options|
+ expose :merged,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
if options[:merged_branch_names]
options[:merged_branch_names].include?(repo_branch.name)
else
@@ -19,27 +23,51 @@ module API
end
end
- expose :protected do |repo_branch, options|
+ expose :protected,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
::ProtectedBranch.protected?(options[:project], repo_branch.name)
end
- expose :developers_can_push do |repo_branch, options|
+ expose :developers_can_push,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
::ProtectedBranch.developers_can?(:push, repo_branch.name, protected_refs: options[:project].protected_branches)
end
- expose :developers_can_merge do |repo_branch, options|
+ expose :developers_can_merge,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
::ProtectedBranch.developers_can?(:merge, repo_branch.name, protected_refs: options[:project].protected_branches)
end
- expose :can_push do |repo_branch, options|
+ expose :can_push,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
Gitlab::UserAccess.new(options[:current_user], container: options[:project]).can_push_to_branch?(repo_branch.name)
end
- expose :default do |repo_branch, options|
+ expose :default,
+ documentation: {
+ type: 'boolean',
+ example: true
+ } do |repo_branch, options|
options[:project].default_branch == repo_branch.name
end
- expose :web_url do |repo_branch|
+ expose :web_url,
+ documentation: {
+ type: 'string',
+ example: 'https://gitlab.example.com/Commit921/the-dude/-/tree/master'
+ } do |repo_branch|
project_tree_url(options[:project], repo_branch.name)
end
end