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:
parent
9b60214b3a
commit
7c105ec9e9
|
@ -167,7 +167,9 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path, identifier)
|
||||
entries = scm.entries(path, identifier)
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
def branches
|
||||
|
@ -380,6 +382,16 @@ class Repository < ActiveRecord::Base
|
|||
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
|
||||
|
||||
# Deletes repository data
|
||||
|
|
|
@ -63,6 +63,8 @@ class Repository::Bazaar < Repository
|
|||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
|
|
|
@ -66,6 +66,7 @@ class Repository::Cvs < Repository
|
|||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class Repository::Darcs < Repository
|
|||
end
|
||||
end
|
||||
end
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
|
|
|
@ -44,10 +44,6 @@ class Repository::Filesystem < Repository
|
|||
false
|
||||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -94,9 +94,9 @@ class Repository::Git < Repository
|
|||
end
|
||||
|
||||
def entries(path=nil, identifier=nil)
|
||||
scm.entries(path,
|
||||
identifier,
|
||||
options = {:report_last_commit => extra_report_last_commit})
|
||||
entries = scm.entries(path, identifier, :report_last_commit => extra_report_last_commit)
|
||||
load_entries_changesets(entries)
|
||||
entries
|
||||
end
|
||||
|
||||
# With SCMs that have a sequential commit numbering,
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
|
||||
</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 %>
|
||||
<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="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="comments"><%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %></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(entry.changeset.comments, :length => 50) if entry.changeset %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -301,7 +301,8 @@ module Redmine
|
|||
end
|
||||
|
||||
class Entry
|
||||
attr_accessor :name, :path, :kind, :size, :lastrev
|
||||
attr_accessor :name, :path, :kind, :size, :lastrev, :changeset
|
||||
|
||||
def initialize(attributes={})
|
||||
self.name = attributes[:name] if attributes[:name]
|
||||
self.path = attributes[:path] if attributes[:path]
|
||||
|
|
Loading…
Reference in New Issue