Skip to content

Commit ecc0ce5

Browse files
committed
- DiffFile#binary?
-- check binary - attr_reader from, to (I refer to commit sha1.)
1 parent 766be2b commit ecc0ce5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/git/diff.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def initialize(base, from = nil, to = nil)
1818
@from = from.to_s
1919
@to = to.to_s
2020
end
21+
attr_reader :from, :to
2122

2223
def path(path)
2324
@path = path
@@ -82,6 +83,11 @@ def initialize(base, hash)
8283
@src = hash[:src]
8384
@dst = hash[:dst]
8485
@type = hash[:type]
86+
@binary = hash[:binary]
87+
end
88+
89+
def binary?
90+
!!@binary
8591
end
8692

8793
def blob(type = :dst)
@@ -133,11 +139,14 @@ def process_full_diff
133139
final[current_file][:type] = m[1]
134140
final[current_file][:mode] = m[2]
135141
end
142+
if m = /^Binary files /.match(line)
143+
final[current_file][:binary] = true
144+
end
136145
final[current_file][:patch] << "\n" + line
137146
end
138147
end
139148
final.map { |e| [e[0], DiffFile.new(@base, e[1])] }
140149
end
141150

142151
end
143-
end
152+
end

0 commit comments

Comments
 (0)