public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
ability to expand and see what changed in a submodule, from a diff
timcharper (author)
Thu May 22 13:01:10 -0700 2008
commit  47f5ff7e0c761109b9ab7dcd8af1771dbacf2b7f
tree    84ce2b2f9eaa3f36e4ee05dfafbdf696d36620e6
parent  1549a865923abb728c0721189ec93e60f26719ff
...
1
2
3
 
4
5
6
7
 
8
9
10
...
1
2
 
3
4
5
6
 
7
8
9
10
0
@@ -1,10 +1,10 @@
0
 class DiffController < ApplicationController
0
   include SubmoduleHelper
0
-
0
+ include DiffHelper
0
   def diff
0
     show_diff_title unless params[:layout].to_s=="false"
0
     @rev = params[:rev]
0
- @title = params[:title] || "Uncomitted changes"
0
+ @title = params[:title] || "Diff result"
0
     params[:context_lines] = git.config.context_lines if git.config.context_lines
0
     
0
     render("_diff_results", :locals => {
...
6
7
8
 
 
 
 
 
 
 
 
9
...
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -6,4 +6,12 @@ module ApplicationHelper
0
   def git
0
     @git ||= Git.new
0
   end
0
+
0
+ def link_to_relative_file(git, file_path, line = nil)
0
+ if line
0
+ link_to_textmate(git.root_relative_path_for(file_path), git.path_for(file_path), line)
0
+ else
0
+ link_to_mate(git.root_relative_path_for(file_path), git.path_for(file_path))
0
+ end
0
+ end
0
 end
...
17
18
19
20
 
21
22
23
...
17
18
19
 
20
21
22
23
0
@@ -17,7 +17,7 @@
0
     end
0
     open_links[lr] = link_to_remote(lr, :params => { :controller => "log", :action => "open_revision", :file_path => file_path, :revision => side_revision, :line => diff_result[lr][:ln_start], :git_path => git.path })
0
     
0
- file_path_right ? link_to_textmate(git.root_relative_path_for(file_path), git.path_for(file_path_right), start_line_right) : git.root_relative_path_for(file_path)
0
+ file_path_right ? link_to_relative_file(git, file_path_right, start_line_right) : git.root_relative_path_for(file_path)
0
   end
0
 %>
0
 
...
3
4
5
6
 
 
 
 
 
7
8
9
...
3
4
5
 
6
7
8
9
10
11
12
13
0
@@ -3,7 +3,11 @@
0
 <code>
0
   <% diff_results.each do |diff_result| %>
0
     <% next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT %>
0
- <% render "diff/_diff_result", :locals => {:git => git, :diff_result => diff_result, :revision => revision } %>
0
+ <% if diff_result[:mode] == Git::SUBMODULE_MODE %>
0
+ <% render "diff/_submodule_diff_result", :locals => {:git => git, :diff_result => diff_result, :revision => revision } %>
0
+ <% else %>
0
+ <% render "diff/_diff_result", :locals => {:git => git, :diff_result => diff_result, :revision => revision } %>
0
+ <% end %>
0
     <% flush %>
0
   <% end %>
0
 </code>
...
1
2
3
 
 
4
5
6
...
19
20
21
22
 
23
24
25
...
1
2
 
3
4
5
6
7
...
20
21
22
 
23
24
25
26
0
@@ -1,6 +1,7 @@
0
 <div>
0
   <div class="infobox">
0
- <a href="javascript:toggle_diff('<%= branch_name %>', '<%= log_entry[:rev] %>');" id="toggle_link_<%= log_entry[:rev] %>" class="expand_link">+</a>
0
+ <% expanded_detail_dom_id = "detail_#{branch_name}_#{log_entry[:rev]}" %>
0
+ <a href="javascript:toggle_diff('<%= expanded_detail_dom_id %>');" id="toggle_link_<%= expanded_detail_dom_id %>" class="expand_link">+</a>
0
     <span style='float:left'>
0
       <strong><%= short_rev(log_entry[:rev]) %></strong>
0
       committed by
0
@@ -19,6 +20,6 @@
0
       <%= htmlize(log_entry[:msg])%>
0
     </div>
0
     <br clear="both"/>
0
- <%= content_tag :div, :class => "diff", :style => "display: none;", :rev => log_entry[:rev], :branch => branch_name, :path => path, :git_path => git.path, :id => "detail_#{branch_name}_#{log_entry[:rev]}" %>
0
+ <%= content_tag :div, :class => "diff", :style => "display: none;", :rev => log_entry[:rev], :path => path, :git_path => git.path, :id => expanded_detail_dom_id %>
0
   </div>
0
 </div>
0
\ No newline at end of file
...
7
8
9
10
11
12
 
13
14
 
15
16
17
...
7
8
9
 
10
 
11
12
 
13
14
15
16
0
@@ -7,11 +7,10 @@
0
       </span>
0
     </td>
0
     <td>
0
- <% display_path = git.root_relative_path_for(e[:display]) %>
0
       <% if e[:path][-1..-1]=="/" %>
0
- <%= htmlize(display_path) %>
0
+ <%= htmlize(git.root_relative_path_for(e[:display])) %>
0
       <% else %>
0
- <%= link_to_textmate display_path, e[:path] %>
0
+ <%= link_to_relative_file(git, e[:path]) %>
0
       <% end %>
0
     </td>
0
   </tr>
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class SCM::Git::Config < SCM::Git::CommandProxyBase
0
   def [](*params)
0
     scope, key = process_keys(params)
0
     r = base.command(*(["config"] + config_args(scope) + [key]))
0
- r.empty? ? nil : r.gsub(/\n$/, '')
0
+ r.blank? ? nil : r.gsub(/\n$/, '')
0
   end
0
 
0
   def []=(*params)
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
 
21
22
23
...
29
30
31
32
33
 
 
34
35
 
36
37
38
39
 
 
 
 
 
 
 
 
 
 
 
40
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
...
12
13
14
 
 
15
16
17
 
18
19
20
21
 
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -1,23 +1,6 @@
0
-// all_toggled = false;
0
-// function toggle_all() {
0
-// if (all_toggled) {
0
-// $$(".diff").each(function(e) { set_log_visibility($(e).readAttribute("branch"), $(e).readAttribute("rev"), false )});
0
-// all_toggled = false;
0
-// $('toggle_all').update("Expand all");
0
-// }
0
-// else
0
-// {
0
-// $$(".diff").each(function(e) { set_log_visibility($(e).readAttribute("branch"), $(e).readAttribute("rev"), true )});
0
-// all_toggled = true;
0
-// $('toggle_all').update("Collapse all");
0
-// }
0
-// }
0
-
0
-function detail_div_for(branch, rev) { return $("detail_" + branch + "_" + rev) }
0
-
0
-function set_log_visibility(branch, rev, state) {
0
- link = $("toggle_link_" + rev);
0
- detail_div = detail_div_for(branch, rev);
0
+function set_togglable_visibility(dom_id, state) {
0
+ link = $("toggle_link_" + dom_id);
0
+ detail_div = $(dom_id)
0
   if (state) {
0
     link.update("-");
0
     detail_div.show();
0
@@ -29,12 +12,22 @@ function set_log_visibility(branch, rev, state) {
0
   }
0
 }
0
 
0
-function toggle_diff(branch, rev) {
0
- e = detail_div_for(branch, rev);
0
+function toggle_diff(dom_id) {
0
+ e = $(dom_id)
0
   if (! e.readAttribute("loaded")) {
0
- e.update(dispatch({controller: 'diff', action: 'diff', branch: branch, revision: rev, git_path: e.readAttribute("git_path"), path: (e.readAttribute("path") || ""), layout: false}))
0
+ e.update(dispatch({controller: 'diff', action: 'diff', revision: e.readAttribute("rev"), git_path: e.readAttribute("git_path"), path: (e.readAttribute("path") || ""), layout: false}))
0
     e.setAttribute("loaded");
0
   }
0
   
0
- set_log_visibility( branch, rev, ! e.visible() );
0
+ set_togglable_visibility( dom_id, ! e.visible() );
0
+}
0
+
0
+function toggle_log(dom_id) {
0
+ e = $(dom_id)
0
+ if (! e.readAttribute("loaded")) {
0
+ e.update(dispatch({controller: 'log', action: 'log', revisions: e.readAttribute("revisions"), git_path: e.readAttribute("git_path"), path: (e.readAttribute("path") || ""), layout: false}))
0
+ // e.setAttribute("loaded");
0
+ }
0
+
0
+ set_togglable_visibility( dom_id, ! e.visible() );
0
 }
...
37
38
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
0
@@ -37,4 +37,28 @@ describe DiffController do
0
       @output.should include("prototype.js")
0
     end
0
   end
0
+
0
+ describe "diffing submodules" do
0
+ before(:each) do
0
+ @git.should_receive(:diff).
0
+ and_return(
0
+ parse_diff(fixture_file("submodules.diff"))
0
+ )
0
+ @output = capture_output do
0
+ dispatch(:controller => "diff", :action => "diff")
0
+ end
0
+ end
0
+
0
+ it "should report the added submodule" do
0
+ @output.should include("Submodule added")
0
+ end
0
+
0
+ it "should report the deleted submodule" do
0
+ @output.should include("Submodule deleted")
0
+ end
0
+
0
+ it "should report the modified submodule" do
0
+ @output.should include("Submodule modified")
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.