#93: added icon for submodule, fixed messages of Tree, Submodule, Blob

This commit is contained in:
Vokhmin Alexey V 2013-04-10 15:40:11 +04:00
parent 511ccbc61a
commit 0bc804e69d
4 changed files with 36 additions and 48 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,5 +1,10 @@
%td - if commit
%span{:style => "display: none;"}= date = commit.committed_date || commit.authored_date %td
= l(date, :format => :short) %span{:style => "display: none;"}= date = commit.committed_date || commit.authored_date
%td= commit.short_message = l(date, :format => :short)
%td= (commit.committer || commit.author).name %td= commit.short_message
%td= (commit.committer || commit.author).name
- else
%td
%td
%td

View File

@ -20,32 +20,21 @@
%td==   %td==  
%td==   %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 %tr
%td %td
- entry_path = File.join([@path.present? ? @path : nil, entry.name].compact) - if node.is_a? Grit::Tree
- 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
.pic= image_tag 'folder.png' .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 = 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

View File

@ -70,24 +70,18 @@ module Modules
end end
def tree_info(tree, treeish = nil, path = nil) def tree_info(tree, treeish = nil, path = nil)
treeish ||= tree.id grouped = tree.contents.sort_by{|c| c.name.downcase}.group_by(&:class)
# initialize result as hash of <tree_entry> => nil [
res = (tree.trees.sort + tree.blobs.sort).inject({}){|h, e| h.merge!({e => nil})} grouped[Grit::Tree],
# fills result vith commits that describes this file grouped[Grit::Blob],
res = res.inject(res) do |h, (entry, commit)| grouped[Grit::Submodule]
if commit.nil? and entry.respond_to?(:name) # only if commit == nil ].compact.flatten.map do |node|
# ... find last commit corresponds to this file ... node_path = File.join([path.present? ? path : nil, node.name].compact)
c = repo.log(treeish, File.join([path, entry.name].compact), :max_count => 1).first [
# ... and add it to result. node,
h[entry] = c node_path,
# find another files, that linked to this commit and set them their commit repo.log(treeish, node_path, :max_count => 1).first
# 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
end end
end end