Merge pull request #94 from abf/rosa-build:93-support-git-submodule

#93: Support git submodule
This commit is contained in:
warpc 2013-04-11 14:15:47 +04:00
commit 8fdcb33a83
5 changed files with 67 additions and 55 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -2019,3 +2019,10 @@ article .activity .top {
.cm-s-default.md_and_cm p img {
max-width: 800px;
}
.tablesorter.project {
.th1 {
width: auto;
}
th { text-align: center; }
}

View File

@ -1514,33 +1514,31 @@ div.fork p {
/* Project main page */
table.tablesorter.project .th1 {
.tablesorter.project {
.th1 {
width: 130px;
/*padding-left: 17px;*/
}
table.tablesorter.project .th2 {
.th2 {
width: 110px;
/*padding-left: 17px;*/
}
table.tablesorter.project .th3 {
.th3 {
width: 450px;
}
table.tablesorter.project .th4 {
.th4 {
/*padding-left: 17px;*/
}
table.tablesorter.project div.name {
.name {
float: left;
margin-top: 0px;
}
table.tablesorter.project div.pic {
.pic {
float: left;
padding-right: 5px;
}
}
a.files-see {
color: #292929;

View File

@ -20,18 +20,31 @@
%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')
- if 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')
= '@'
= link_to(node.id[0..6], "#{url}/tree/#{node.id}", :class => 'files-see')
- else
.pic= image_tag 'folder.png'
.name= link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see')
- options = [@project, @treeish, node_path]
- if node.is_a?(Grit::Tree)
- pic = 'folder.png'
- path = tree_path *options
.pic= image_tag pic || 'code.png'
.name= link_to(node.name, path || blob_path(*options), :class => 'files-see')
- 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

View File

@ -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