#93: added icon for submodule, fixed messages of Tree, Submodule, Blob
This commit is contained in:
parent
511ccbc61a
commit
0bc804e69d
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -1,5 +1,10 @@
|
|||
%td
|
||||
%span{:style => "display: none;"}= date = commit.committed_date || commit.authored_date
|
||||
= l(date, :format => :short)
|
||||
%td= commit.short_message
|
||||
%td= (commit.committer || commit.author).name
|
||||
- if commit
|
||||
%td
|
||||
%span{:style => "display: none;"}= date = commit.committed_date || commit.authored_date
|
||||
= l(date, :format => :short)
|
||||
%td= commit.short_message
|
||||
%td= (commit.committer || commit.author).name
|
||||
- else
|
||||
%td
|
||||
%td
|
||||
%td
|
|
@ -20,32 +20,21 @@
|
|||
%td==
|
||||
%td==
|
||||
%td==
|
||||
- @project.tree_info(@tree, @treeish, @path).each_pair do |entry, commit|
|
||||
- @project.tree_info(@tree, @treeish, @path).each do |node, node_path, commit|
|
||||
%tr
|
||||
%td
|
||||
- entry_path = File.join([@path.present? ? @path : nil, entry.name].compact)
|
||||
- if entry.is_a? Grit::Blob
|
||||
.pic= image_tag 'code.png'
|
||||
.name= link_to(entry.name, blob_path(@project, @treeish, entry_path), :class => 'files-see')
|
||||
- else
|
||||
- if node.is_a? Grit::Tree
|
||||
.pic= image_tag 'folder.png'
|
||||
.name= link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see')
|
||||
.name= link_to(node.name, tree_path(@project, @treeish, node_path), :class => 'files-see')
|
||||
- elsif node.is_a? Grit::Submodule
|
||||
.pic= image_tag 'folder-submodule.png'
|
||||
.name
|
||||
- url = node.url(@treeish).gsub(/^git/, 'http').gsub(/.git$/, '')
|
||||
= link_to(node.name, url, :class => 'files-see')
|
||||
= '@'
|
||||
- id = node.id
|
||||
= link_to(id[0..6], "#{url}/tree/#{id}", :class => 'files-see')
|
||||
- else
|
||||
.pic= image_tag 'code.png'
|
||||
.name= link_to(node.name, tree_path(@project, @treeish, node_path), :class => 'files-see')
|
||||
= render 'commit_info', :commit => commit
|
||||
|
||||
- commit = @project.tree_info(@project.repo.tree(@treeish), @treeish, nil).detect{ |e, c| e.name == '.gitmodules' && c }.try(:last)
|
||||
- if commit
|
||||
- Grit::Submodule.config(@project.repo).each do |name, options|
|
||||
- folder = options['path'].split('/').last
|
||||
- if options['path'] == [@path, folder].compact.join('/')
|
||||
%tr
|
||||
%td
|
||||
.pic= image_tag 'folder.png'
|
||||
- url = options['url'].gsub(/^git/, 'http').gsub(/.git$/, '')
|
||||
.name
|
||||
= link_to(folder, url, :class => 'files-see')
|
||||
= '@'
|
||||
- id = options['id']
|
||||
= link_to(id[0..6], "#{url}/tree/#{id}", :class => 'files-see')
|
||||
= render 'commit_info', :commit => commit
|
||||
|
||||
|
||||
|
|
|
@ -70,24 +70,18 @@ module Modules
|
|||
end
|
||||
|
||||
def tree_info(tree, treeish = nil, path = nil)
|
||||
treeish ||= tree.id
|
||||
# initialize result as hash of <tree_entry> => nil
|
||||
res = (tree.trees.sort + tree.blobs.sort).inject({}){|h, e| h.merge!({e => nil})}
|
||||
# fills result vith commits that describes this file
|
||||
res = res.inject(res) do |h, (entry, commit)|
|
||||
if commit.nil? and entry.respond_to?(:name) # only if commit == nil
|
||||
# ... find last commit corresponds to this file ...
|
||||
c = repo.log(treeish, File.join([path, entry.name].compact), :max_count => 1).first
|
||||
# ... and add it to result.
|
||||
h[entry] = c
|
||||
# find another files, that linked to this commit and set them their commit
|
||||
# c.diffs.map{|diff| diff.b_path.split(File::SEPARATOR, 2).first}.each do |name|
|
||||
# h.each_pair do |k, v|
|
||||
# h[k] = c if k.name == name and v.nil?
|
||||
# end
|
||||
# end
|
||||
end
|
||||
h
|
||||
grouped = tree.contents.sort_by{|c| c.name.downcase}.group_by(&:class)
|
||||
[
|
||||
grouped[Grit::Tree],
|
||||
grouped[Grit::Blob],
|
||||
grouped[Grit::Submodule]
|
||||
].compact.flatten.map do |node|
|
||||
node_path = File.join([path.present? ? path : nil, node.name].compact)
|
||||
[
|
||||
node,
|
||||
node_path,
|
||||
repo.log(treeish, node_path, :max_count => 1).first
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue