From a7f0a861cb9ebb616952b047e36869da0074cbd0 Mon Sep 17 00:00:00 2001 From: Mathias Meyer Date: Wed, 18 Jun 2014 11:23:18 +0200 Subject: [PATCH] Fetch last build if no branch specified. This restores backwards compatibility with the current behaviour rather than defaulting to master. Though the latter would probably the right thing to do in the longer term. --- lib/travis/api/app/responders/xml.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index bc80f254..10c743a5 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -6,14 +6,14 @@ module Travis::Api::App::Responders class Xml < Base TEMPLATE_ERB = ERB.new <<-EOF -<% @resource.each do |r| %> - <% next if r.last_completed_build(branch).nil? -%> +<% @resource.each do |repository| %> + <% next if build(repository).nil? -%> <% end %> @@ -44,7 +44,15 @@ module Travis::Api::App::Responders end def branch - params[:branch].present? ? params[:branch] : 'master' + params[:branch] + end + + def build(repository) + if branch.present? + repository.last_complete_build(branch) + else + repository.last_build + end end private