lib/rubyfocus/fetchers/fetcher.rb in rubyfocus-0.5.4 vs lib/rubyfocus/fetchers/fetcher.rb in rubyfocus-0.5.5

- old
+ new

@@ -36,20 +36,20 @@ # Returns the contents of a given patch def patch(filename) raise RuntimeError, "Method Fetcher#patch called for abstract class Fetcher." end - # Returns the latest patch + # Returns the ID of head - the latest patch committed to the database. def head - @head ||= patches.sort.last + @head ||= (patches.empty? ? base_id : patches.sort.last.to_id) end # Can you reach head from the given ID? def can_reach_head_from?(id) patch_array = patches.select{ |p| p.from_ids.include?(id) } until patch_array.empty? p = patch_array.first - return true if p == self.head + return true if p.to_id == self.head next_patches = patches.select{ |np| np.from_ids.include? p.to_id } patch_array = patch_array[1..-1] + next_patches end return false \ No newline at end of file