[refs #674] fix get last published commit

This commit is contained in:
Alexander Machehin 2012-12-04 15:59:16 +06:00
parent 42e76f5fa6
commit 9e5a7e3fdb
2 changed files with 6 additions and 4 deletions

View File

@ -219,7 +219,7 @@ class BuildList < ActiveRecord::Base
def actualize_packages
ActiveRecord::Base.transaction do
# packages from previous build_list
self.last_published.packages.update_all :actual => false
self.last_published.limit(2).last.packages.update_all :actual => false
self.packages.update_all :actual => true
end
end
@ -439,6 +439,6 @@ class BuildList < ActiveRecord::Base
.for_platform(self.build_for_platform_id)
.scoped_to_arch(self.arch_id)
.for_status(BUILD_PUBLISHED)
.recent.limit(2).last
.recent
end
end

View File

@ -28,8 +28,10 @@ module Modules
end
def set_last_published_commit
if self.respond_to? :last_published_commit_hash
self.last_published_commit_hash = self.last_published.try :commit_hash
return unless self.respond_to? :last_published_commit_hash # product?
last_commit = self.last_published.first.try :commit_hash
if last_commit && self.project.repo.commit(last_commit).present? # commit(nil) is not nil!
self.last_published_commit_hash = last_commit
end
end
end