Skip to content

Commit bbf4444

Browse files
author
pivotal
committed
Whitespace.
1 parent b79de3a commit bbf4444

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

lib/git/diff.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module Git
2-
2+
33
# object that holds the last X commits on given branch
44
class Diff
55
include Enumerable
6-
6+
77
def initialize(base, from = nil, to = nil)
88
@base = base
99
@from = from.to_s
@@ -15,60 +15,60 @@ def initialize(base, from = nil, to = nil)
1515
@stats = nil
1616
end
1717
attr_reader :from, :to
18-
18+
1919
def path(path)
2020
@path = path
2121
return self
2222
end
23-
23+
2424
def size
2525
cache_stats
2626
@stats[:total][:files]
2727
end
28-
28+
2929
def lines
3030
cache_stats
3131
@stats[:total][:lines]
3232
end
33-
33+
3434
def deletions
3535
cache_stats
3636
@stats[:total][:deletions]
3737
end
38-
38+
3939
def insertions
4040
cache_stats
4141
@stats[:total][:insertions]
4242
end
43-
43+
4444
def stats
4545
cache_stats
4646
@stats
4747
end
48-
48+
4949
# if file is provided and is writable, it will write the patch into the file
5050
def patch(file = nil)
5151
cache_full
5252
@full_diff
5353
end
5454
alias_method :to_s, :patch
55-
55+
5656
# enumerable methods
57-
57+
5858
def [](key)
5959
process_full
6060
@full_diff_files.assoc(key)[1]
6161
end
62-
62+
6363
def each(&block) # :yields: each Git::DiffFile in turn
6464
process_full
6565
@full_diff_files.map { |file| file[1] }.each(&block)
6666
end
67-
67+
6868
class DiffFile
6969
attr_accessor :patch, :path, :mode, :src, :dst, :type
7070
@base = nil
71-
71+
7272
def initialize(base, hash)
7373
@base = base
7474
@patch = hash[:patch]
@@ -83,7 +83,7 @@ def initialize(base, hash)
8383
def binary?
8484
!!@binary
8585
end
86-
86+
8787
def blob(type = :dst)
8888
if type == :src
8989
@base.object(@src) if @src != '0000000'
@@ -92,36 +92,36 @@ def blob(type = :dst)
9292
end
9393
end
9494
end
95-
95+
9696
private
97-
97+
9898
def cache_full
9999
unless @full_diff
100100
@full_diff = @base.lib.diff_full(@from, @to, {:path_limiter => @path})
101101
end
102102
end
103-
103+
104104
def process_full
105105
unless @full_diff_files
106106
cache_full
107107
@full_diff_files = process_full_diff
108108
end
109109
end
110-
110+
111111
def cache_stats
112112
unless @stats
113113
@stats = @base.lib.diff_stats(@from, @to, {:path_limiter => @path})
114114
end
115115
end
116-
116+
117117
# break up @diff_full
118118
def process_full_diff
119119
final = {}
120120
current_file = nil
121121
@full_diff.split("\n").each do |line|
122122
if m = /diff --git a\/(.*?) b\/(.*?)/.match(line)
123123
current_file = m[1]
124-
final[current_file] = {:patch => line, :path => current_file,
124+
final[current_file] = {:patch => line, :path => current_file,
125125
:mode => '', :src => '', :dst => '', :type => 'modified'}
126126
else
127127
if m = /index (.......)\.\.(.......)( ......)*/.match(line)
@@ -136,11 +136,11 @@ def process_full_diff
136136
if m = /^Binary files /.match(line)
137137
final[current_file][:binary] = true
138138
end
139-
final[current_file][:patch] << "\n" + line
139+
final[current_file][:patch] << "\n" + line
140140
end
141141
end
142142
final.map { |e| [e[0], DiffFile.new(@base, e[1])] }
143143
end
144-
144+
145145
end
146146
end

0 commit comments

Comments
 (0)