From cb808207b42268a86dfcb3879f7cd4032b4d87eb Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 9 Apr 2013 23:24:52 +0400 Subject: [PATCH 1/6] #93: showed submodules --- .../projects/git/trees/_commit_info.html.haml | 5 ++++ app/views/projects/git/trees/_show.html.haml | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 app/views/projects/git/trees/_commit_info.html.haml diff --git a/app/views/projects/git/trees/_commit_info.html.haml b/app/views/projects/git/trees/_commit_info.html.haml new file mode 100644 index 000000000..3f9ad0dc1 --- /dev/null +++ b/app/views/projects/git/trees/_commit_info.html.haml @@ -0,0 +1,5 @@ +%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 \ No newline at end of file diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 35bae8bea..65333e439 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -30,8 +30,22 @@ - else .pic= image_tag 'folder.png' .name= link_to(entry.name, tree_path(@project, @treeish, entry_path), :class => 'files-see') - %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 \ No newline at end of file + = render 'commit_info', :commit => commit + + - commit = @project.tree_info(@project.repo.tree(@treeish), @treeish, nil).detect{ |e, c| e.name == '.gitmodules' && c }.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 + + From 511ccbc61a1abff3511946aee103c20dd9608d0e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 10 Apr 2013 13:15:53 +0400 Subject: [PATCH 2/6] #93: update styles --- app/assets/stylesheets/design/custom.scss | 7 +++ app/assets/stylesheets/design/main.scss | 48 ++++++++++---------- app/views/projects/git/trees/_show.html.haml | 2 +- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 894c7097e..075500d6f 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -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; } +} \ No newline at end of file diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index 0135b0731..29beb1cbf 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -1514,32 +1514,30 @@ div.fork p { /* Project main page */ -table.tablesorter.project .th1 { - width: 130px; - /*padding-left: 17px;*/ -} +.tablesorter.project { -table.tablesorter.project .th2 { - width: 110px; - /*padding-left: 17px;*/ -} - -table.tablesorter.project .th3 { - width: 450px; -} - -table.tablesorter.project .th4 { - /*padding-left: 17px;*/ -} - -table.tablesorter.project div.name { - float: left; - margin-top: 0px; -} - -table.tablesorter.project div.pic { - float: left; - padding-right: 5px; + .th1 { + width: 130px; + /*padding-left: 17px;*/ + } + .th2 { + width: 110px; + /*padding-left: 17px;*/ + } + .th3 { + width: 450px; + } + .th4 { + /*padding-left: 17px;*/ + } + .name { + float: left; + margin-top: 0px; + } + .pic { + float: left; + padding-right: 5px; + } } a.files-see { diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 65333e439..ec36e1e02 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -32,7 +32,7 @@ .name= link_to(entry.name, tree_path(@project, @treeish, entry_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 }.last + - 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 From 0bc804e69df6c15681079eb034e7cbab3bd32105 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 10 Apr 2013 15:40:11 +0400 Subject: [PATCH 3/6] #93: added icon for submodule, fixed messages of Tree, Submodule, Blob --- app/assets/images/folder-submodule.png | Bin 0 -> 3289 bytes .../projects/git/trees/_commit_info.html.haml | 15 ++++--- app/views/projects/git/trees/_show.html.haml | 39 +++++++----------- lib/modules/models/git.rb | 30 ++++++-------- 4 files changed, 36 insertions(+), 48 deletions(-) create mode 100644 app/assets/images/folder-submodule.png diff --git a/app/assets/images/folder-submodule.png b/app/assets/images/folder-submodule.png new file mode 100644 index 0000000000000000000000000000000000000000..651ee74233c494d95a29dbf88a0b9125e822fec6 GIT binary patch literal 3289 zcmV;~3?}o5P)4Tx07wm;mUmPX*B8g%%xo{TU6vwc>AklFq%OTkl_mFQv@x1^BM1TV}0C2duqR=S6Xn?LjUp6xrb&~O43j*Nv zEr418u3H3zGns$s|L;SQD-ufpfWpxLJ03rmi*g~#S@{x?OrJ!Vo{}kJ7$ajbnjp%m zGEV!%=70KpVow?KvV}a4moSaFCQKV= zXBIPnpP$8-NG!rR+)R#`$7JVZi#Wn10DSspSrkx`)s~4C+0n+?(b2-z5-tDd^^cpM zz5W?wz5V3zGUCskL5!X++LzcbT23thtSPiMTfS&1I{|204}j|3FPi>70OSh+Xzlyz zdl<5LNtZ}OE>>3g`T3RtKG#xK(9i3CI(+v0d-&=+OWAp!Ysd8Ar*foO5~i%E+?=c& zshF87;&Ay)i~kOm zCIB-Z!^JGdti+UJsxgN!t(Y#%b<8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&5F%x&L(6hXP*!%2{VOVIa)adIsGCtQITk9vCHD^izmgw;`&@D zcVTY3gpU49^+=7S>!rha?s+wNZ}MaEj~6Hw2n%|am@e70WNfM5(r=exmT{MLF4tMU zX8G_6uNC`OLMu~NcCOM}Rk&(&wg2ivYe;J{*Zj2BdTsgISLt?eJQu}$~QLORDCnMIdyYynPb_W zEx0YhEw{FMY&}%2SiZD;WLxOA)(U1tamB0cN!u@1+E?z~LE0hRF;o>&)xJ}I=a!xC ztJAA*)_B)6@6y<{Y1i~_-tK`to_m`1YVIxB`);3L-|hYW`&(-bYby`n4&)tpTo+T< z{VnU;hI;k-lKKw^g$IWYMIP#EaB65ctZ}%k5pI+=jvq-pa_u{x@7kLzn)Wv{noEv? zqtc^Kzfb=D*0JDYoyS?nn|?6(VOI;SrMMMpUD7()mfkkh9^c-7BIrbChiga6kCs0k zJgIZC=9KcOveTr~g{NoFEIl)IR&;jaT-v#j&ZN$J=i|=b=!)p-y%2oi(nY_E=exbS z&s=i5bn>#xz3Ke>~2=f&N;yEFGz-^boBexUH6@}b7V+Mi8+ZXR+R zIyLMw-18{v(Y+Dw$g^K^e|bMz_?Y^*a!h-y;fd{&ljDBl*PbqTI{HlXY-Xb9SH)j< zJvV;-!*8Cy^-RW1j=m7TnEk!W$Z0xb17g2aR#o7AH##e;lWmx=iJuI0E6nE=R>wUKBX}nhN5P2 z;#lC0lMpNWz^-pRxY=F5b4#ftw~J~zE9c90dzH0U^AOF#;8L7Hyfx27Idf;9KJWhq XFrN%7_`Q3100000NkvXXu0mjfN`O7p literal 0 HcmV?d00001 diff --git a/app/views/projects/git/trees/_commit_info.html.haml b/app/views/projects/git/trees/_commit_info.html.haml index 3f9ad0dc1..cfd84ecda 100644 --- a/app/views/projects/git/trees/_commit_info.html.haml +++ b/app/views/projects/git/trees/_commit_info.html.haml @@ -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 \ No newline at end of file +- 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 \ No newline at end of file diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index ec36e1e02..6567e49be 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -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 - - diff --git a/lib/modules/models/git.rb b/lib/modules/models/git.rb index 9bcd5daa7..43cc16965 100644 --- a/lib/modules/models/git.rb +++ b/lib/modules/models/git.rb @@ -70,24 +70,18 @@ module Modules end def tree_info(tree, treeish = nil, path = nil) - treeish ||= tree.id - # initialize result as hash of => 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 From 7fe0079bd7ada51d6b9fca9b50aa923dbaf362b0 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 10 Apr 2013 15:46:39 +0400 Subject: [PATCH 4/6] #93: some refactoring --- app/views/projects/git/trees/_show.html.haml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 6567e49be..72f01c2e6 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -23,10 +23,7 @@ - @project.tree_info(@tree, @treeish, @path).each do |node, node_path, commit| %tr %td - - if node.is_a? Grit::Tree - .pic= image_tag 'folder.png' - .name= link_to(node.name, tree_path(@project, @treeish, node_path), :class => 'files-see') - - elsif node.is_a? Grit::Submodule + - if node.is_a? Grit::Submodule .pic= image_tag 'folder-submodule.png' .name - url = node.url(@treeish).gsub(/^git/, 'http').gsub(/.git$/, '') @@ -35,6 +32,7 @@ - id = node.id = link_to(id[0..6], "#{url}/tree/#{id}", :class => 'files-see') - else - .pic= image_tag 'code.png' + .pic= image_tag (node.is_a?(Grit::Tree) ? 'folder.png' : 'code.png') .name= link_to(node.name, tree_path(@project, @treeish, node_path), :class => 'files-see') + = render 'commit_info', :commit => commit From c7603fd607614405cc4690bd9db35adc78de38c7 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 10 Apr 2013 15:57:07 +0400 Subject: [PATCH 5/6] #93: fixed path to blob --- app/views/projects/git/trees/_show.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 72f01c2e6..4447201ce 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -32,7 +32,11 @@ - id = node.id = link_to(id[0..6], "#{url}/tree/#{id}", :class => 'files-see') - else - .pic= image_tag (node.is_a?(Grit::Tree) ? 'folder.png' : 'code.png') - .name= link_to(node.name, tree_path(@project, @treeish, node_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') = render 'commit_info', :commit => commit From 8b77323f5fb66fcc9bf31f25362c502e992a8a0d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 11 Apr 2013 14:09:32 +0400 Subject: [PATCH 6/6] #93: remove _commit_info partial --- .../projects/git/trees/_commit_info.html.haml | 10 ---------- app/views/projects/git/trees/_show.html.haml | 14 +++++++++++--- 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 app/views/projects/git/trees/_commit_info.html.haml diff --git a/app/views/projects/git/trees/_commit_info.html.haml b/app/views/projects/git/trees/_commit_info.html.haml deleted file mode 100644 index cfd84ecda..000000000 --- a/app/views/projects/git/trees/_commit_info.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- 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 \ No newline at end of file diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 4447201ce..3a5feb259 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -29,8 +29,7 @@ - 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') + = link_to(node.id[0..6], "#{url}/tree/#{node.id}", :class => 'files-see') - else - options = [@project, @treeish, node_path] - if node.is_a?(Grit::Tree) @@ -39,4 +38,13 @@ .pic= image_tag pic || 'code.png' .name= link_to(node.name, path || blob_path(*options), :class => 'files-see') - = render 'commit_info', :commit => commit + - 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