public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
make diff parser also parse the file mode
timcharper (author)
Thu May 22 10:24:43 -0700 2008
commit  d1b253bb056d96077e36b8e101c0c838162f025a
tree    cbe301a95b40b0dbe5eb01889c591a9d14aaa257
parent  b6d99d213151e5a79b6c812b97e822181071bf60
...
23
24
25
 
26
27
28
...
23
24
25
26
27
28
29
0
@@ -23,6 +23,7 @@ module SCM
0
     }
0
     
0
     DEFAULT_DIFF_LIMIT = 3000
0
+ SUBMODULE_MODE = "160000"
0
     
0
     def short_rev(rev)
0
       rev.to_s[0..7]
...
149
150
151
152
153
 
 
 
 
154
155
156
 
 
157
158
159
...
149
150
151
 
152
153
154
155
156
157
158
 
159
160
161
162
163
0
@@ -149,11 +149,15 @@ module Parsers
0
     diff_content.split("\n").each do |line|
0
       case line
0
       when /^diff \-\-git/
0
- when /^index (([a-f0-9]+)..([a-f0-9]+)){0,1}/i
0
         current = {:left => {}, :right => {}, :lines => []}
0
+ when /^(deleted|new) file mode (\d{6})$/
0
+ current[:status] = $1.to_sym
0
+ current[:mode] = $2
0
+ when /^index (([a-f0-9]+)..([a-f0-9]+)){0,1}( (\d{6}))?/i
0
         current[:left][:index] = $2
0
         current[:right][:index] = $3
0
-
0
+ current[:mode] ||= $5
0
+ current[:status] ||= :modified
0
         output << current
0
         /([0-9a-f]+)\.\.([0-9a-f]+) ([0-9]+)/i.match($1)
0
         current[:index_start] = $1
...
38
39
40
 
 
 
 
41
42
43
...
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
...
38
39
40
41
42
43
44
45
46
47
...
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
0
@@ -38,6 +38,10 @@ describe Git do
0
       @lines.last[:ln_right].should == "EOF"
0
       @lines.last[:ln_left].should == "EOF"
0
     end
0
+
0
+ it "should parse the file mode" do
0
+ @results.first[:mode].should == "100644"
0
+ end
0
   end
0
   
0
   describe "when parse a diff with line breaks" do
0
@@ -74,4 +78,26 @@ describe Git do
0
       @lines.map{|l| l[:ln_right]}.should == [nil, nil, 1, 2, 3, "EOF"]
0
     end
0
   end
0
+
0
+ describe "parsing new and deleted files" do
0
+ before(:each) do
0
+ @results = @diff.parse_diff(fixture_file("submodules.diff"))
0
+ end
0
+
0
+ it "should be status :new for new files" do
0
+ @results[0][:status].should == :new
0
+ end
0
+
0
+ it "should pick up the mode from the 'new file mode 160000' line" do
0
+ @results[0][:mode].should == "160000"
0
+ end
0
+
0
+ it "should be status :deleted for deleted files" do
0
+ @results[1][:status].should == :deleted
0
+ end
0
+
0
+ it "should pick up the mode from the 'deleted file mode 160000' line" do
0
+ @results[1][:mode].should == "160000"
0
+ end
0
+ end
0
 end

Comments

    No one has commented yet.