Merge branch 'master' into cd-v3-parity

Keeping my branch up to date with the master
This commit is contained in:
carlad 2015-09-08 12:21:49 +02:00
commit 9d7a01e60c
4 changed files with 33 additions and 2 deletions

View File

@ -20,6 +20,16 @@ module Travis::API::V3
read_attribute(:branch)
end
def job_ids
return super unless cached = cached_matrix_ids
# AR 3.2 does not handle pg arrays and the plugins supporting them
# do not work well with jdbc drivers
# TODO: remove this once we're on >= 4.0
cached = cached.gsub(/^{|}$/, '').split(',').map(&:to_i) unless cached.is_a? Array
cached
end
def branch_name=(value)
write_attribute(:branch, value)
end

View File

@ -15,6 +15,7 @@ module Travis::API::V3
list = list.includes(:commit).includes(branch: :last_build).includes(:repository)
list = list.includes(branch: { last_build: :commit }) if includes? 'build.commit'.freeze
list = list.includes(:jobs) if includes? 'build.jobs'.freeze or includes? 'job'.freeze
list
end
end

View File

@ -3,6 +3,26 @@ require 'travis/api/v3/renderer/model_renderer'
module Travis::API::V3
class Renderer::Build < Renderer::ModelRenderer
representation(:minimal, :id, :number, :state, :duration, :event_type, :previous_state, :started_at, :finished_at, :jobs)
representation(:standard, *representations[:minimal], :repository, :branch, :commit )
representation(:standard, *representations[:minimal], :repository, :branch, :commit)
def jobs
return model.jobs if include_full_jobs?
model.job_ids.map { |id| job(id) }
end
private def include_full_jobs?
return true if include? 'build.job'.freeze
return true if include.any? { |i| i.start_with? 'job.'.freeze }
return true if included.any? { |i| i.is_a? Models::Job and i.source_id == model.id }
end
private def job(id)
{
"@type" => "job",
:@href => Renderer.href(:job, script_name: script_name, id: id),
"@representation" => "minimal",
"id" => id
}
end
end
end

View File

@ -3,6 +3,6 @@ require 'travis/api/v3/renderer/model_renderer'
module Travis::API::V3
class Renderer::Job < Renderer::ModelRenderer
representation(:minimal, :id)
representation(:standard, *representations[:minimal], :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner )
representation(:standard, *representations[:minimal], :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner)
end
end