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.
This commit is contained in:
parent
5081bb157f
commit
a7f0a861cb
|
@ -6,14 +6,14 @@ module Travis::Api::App::Responders
|
|||
class Xml < Base
|
||||
TEMPLATE_ERB = ERB.new <<-EOF
|
||||
<Projects>
|
||||
<% @resource.each do |r| %>
|
||||
<% next if r.last_completed_build(branch).nil? -%>
|
||||
<% @resource.each do |repository| %>
|
||||
<% next if build(repository).nil? -%>
|
||||
<Project
|
||||
name="<%= r.slug %>"
|
||||
activity="<%= ACTIVITY[r.last_completed_build(branch).state.to_sym] || ACTIVITY[:default] %>"
|
||||
lastBuildStatus="<%= STATUS[r.last_completed_build(branch).state.to_sym] || STATUS[:default] %>"
|
||||
lastBuildLabel="<%= r.last_completed_build(branch).try(:number) %>"
|
||||
lastBuildTime="<%= r.last_completed_build(branch).finished_at.try(:strftime, '%Y-%m-%dT%H:%M:%S.%L%z') %>"
|
||||
activity="<%= ACTIVITY[build(repository).state.to_sym] || ACTIVITY[:default] %>"
|
||||
lastBuildStatus="<%= STATUS[build(repository).state.to_sym] || STATUS[:default] %>"
|
||||
lastBuildLabel="<%= build(repository).try(:number) %>"
|
||||
lastBuildTime="<%= build(repository).finished_at.try(:strftime, '%Y-%m-%dT%H:%M:%S.%L%z') %>"
|
||||
webUrl="https://<%= Travis.config.client_domain %>/<%= r.slug %>" />
|
||||
<% end %>
|
||||
</Projects>
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user