v3: branches - add default_branch (boolean) property

This commit is contained in:
Konstantin Haase 2015-10-08 18:44:40 +02:00
parent 06486c57a5
commit d7c9a367e9
2 changed files with 6 additions and 2 deletions

View File

@ -4,5 +4,9 @@ module Travis::API::V3
belongs_to :last_build, class_name: 'Travis::API::V3::Models::Build'.freeze belongs_to :last_build, class_name: 'Travis::API::V3::Models::Build'.freeze
has_many :builds, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'builds.id DESC'.freeze, conditions: { event_type: 'push' } has_many :builds, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'builds.id DESC'.freeze, conditions: { event_type: 'push' }
has_many :commits, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'commits.id DESC'.freeze has_many :commits, foreign_key: [:repository_id, :branch], primary_key: [:repository_id, :name], order: 'commits.id DESC'.freeze
def default_branch
name == repository.default_branch_name
end
end end
end end

View File

@ -2,7 +2,7 @@ require 'travis/api/v3/renderer/model_renderer'
module Travis::API::V3 module Travis::API::V3
class Renderer::Branch < Renderer::ModelRenderer class Renderer::Branch < Renderer::ModelRenderer
representation(:minimal, :name, :last_build) representation(:minimal, :name)
representation(:standard, :name, :repository, :last_build, :exists_on_github) representation(:standard, :name, :repository, :default_branch, :exists_on_github, :last_build)
end end
end end