Adds a method to load changesets for repository entries.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9805 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-06-10 18:32:09 +00:00
parent 9b60214b3a
commit 7c105ec9e9
8 changed files with 25 additions and 13 deletions

View File

@ -167,7 +167,9 @@ class Repository < ActiveRecord::Base
end end
def entries(path=nil, identifier=nil) def entries(path=nil, identifier=nil)
scm.entries(path, identifier) entries = scm.entries(path, identifier)
load_entries_changesets(entries)
entries
end end
def branches def branches
@ -380,6 +382,16 @@ class Repository < ActiveRecord::Base
end end
end end
def load_entries_changesets(entries)
if entries
entries.each do |entry|
if entry.lastrev && entry.lastrev.identifier
entry.changeset = find_changeset_by_name(entry.lastrev.identifier)
end
end
end
end
private private
# Deletes repository data # Deletes repository data

View File

@ -63,6 +63,8 @@ class Repository::Bazaar < Repository
end end
end end
end end
load_entries_changesets(entries)
entries
end end
def fetch_changesets def fetch_changesets

View File

@ -66,6 +66,7 @@ class Repository::Cvs < Repository
end end
end end
end end
load_entries_changesets(entries)
entries entries
end end

View File

@ -66,6 +66,7 @@ class Repository::Darcs < Repository
end end
end end
end end
load_entries_changesets(entries)
entries entries
end end

View File

@ -44,10 +44,6 @@ class Repository::Filesystem < Repository
false false
end end
def entries(path=nil, identifier=nil)
scm.entries(path, identifier)
end
def fetch_changesets def fetch_changesets
nil nil
end end

View File

@ -94,9 +94,9 @@ class Repository::Git < Repository
end end
def entries(path=nil, identifier=nil) def entries(path=nil, identifier=nil)
scm.entries(path, entries = scm.entries(path, identifier, :report_last_commit => extra_report_last_commit)
identifier, load_entries_changesets(entries)
options = {:report_last_commit => extra_report_last_commit}) entries
end end
# With SCMs that have a sequential commit numbering, # With SCMs that have a sequential commit numbering,

View File

@ -29,12 +29,11 @@
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
</td> </td>
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td> <td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
<% changeset = @repository.find_changeset_by_name(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
<% if @repository.report_last_commit %> <% if @repository.report_last_commit %>
<td class="revision"><%= link_to_revision(changeset, @repository) if changeset %></td> <td class="revision"><%= link_to_revision(entry.changeset, @repository) if entry.changeset %></td>
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> <td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
<td class="author"><%= changeset.nil? ? h(Redmine::CodesetUtil.replace_invalid_utf8(entry.lastrev.author.to_s.split('<').first)) : h(changeset.author) if entry.lastrev %></td> <td class="author"><%= entry.changeset.nil? ? h(Redmine::CodesetUtil.replace_invalid_utf8(entry.lastrev.author.to_s.split('<').first)) : h(entry.changeset.author) if entry.lastrev %></td>
<td class="comments"><%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %></td> <td class="comments"><%=h truncate(entry.changeset.comments, :length => 50) if entry.changeset %></td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>

View File

@ -301,7 +301,8 @@ module Redmine
end end
class Entry class Entry
attr_accessor :name, :path, :kind, :size, :lastrev attr_accessor :name, :path, :kind, :size, :lastrev, :changeset
def initialize(attributes={}) def initialize(attributes={})
self.name = attributes[:name] if attributes[:name] self.name = attributes[:name] if attributes[:name]
self.path = attributes[:path] if attributes[:path] self.path = attributes[:path] if attributes[:path]