Class: Git::Diff::DiffFile
- Inherits:
-
Object
- Object
- Git::Diff::DiffFile
- Defined in:
- lib/git/diff.rb
Overview
Information about a single changed file within a Git::Diff
Constant Summary collapse
- NIL_BLOB_REGEXP =
Regexp matching a nil blob SHA (all-zero hash of 4 to 40 hex digits)
/\A0{4,40}\z/
Instance Attribute Summary collapse
-
#dst ⇒ String
The destination (post-change) blob SHA.
-
#mode ⇒ String
The file mode.
-
#patch ⇒ String?
The raw diff patch text for this file.
-
#path ⇒ String?
The file path relative to the repository root.
-
#src ⇒ String
The source (pre-change) blob SHA.
-
#type ⇒ String
The type of change.
Instance Method Summary collapse
-
#binary? ⇒ Boolean
Returns true if this file is a binary file.
-
#blob(type = :dst) ⇒ Git::Object::Blob?
Returns the blob object for this file.
-
#initialize(base, hash)
constructor
Creates a new DiffFile from parsed diff data.
Constructor Details
#initialize(base, hash)
Creates a new DiffFile from parsed diff data
296 297 298 299 300 301 302 303 304 305 |
# File 'lib/git/diff.rb', line 296 def initialize(base, hash) @base = base @patch = hash[:patch] @path = hash[:path] @mode = hash[:mode] @src = hash[:src] @dst = hash[:dst] @type = hash[:type] @binary = hash[:binary] end |
Instance Attribute Details
#dst ⇒ String
The destination (post-change) blob SHA
269 270 271 |
# File 'lib/git/diff.rb', line 269 def dst @dst end |
#mode ⇒ String
The file mode
257 258 259 |
# File 'lib/git/diff.rb', line 257 def mode @mode end |
#patch ⇒ String?
The raw diff patch text for this file
245 246 247 |
# File 'lib/git/diff.rb', line 245 def patch @patch end |
#path ⇒ String?
The file path relative to the repository root
251 252 253 |
# File 'lib/git/diff.rb', line 251 def path @path end |
#src ⇒ String
The source (pre-change) blob SHA
263 264 265 |
# File 'lib/git/diff.rb', line 263 def src @src end |
#type ⇒ String
The type of change
275 276 277 |
# File 'lib/git/diff.rb', line 275 def type @type end |
Instance Method Details
#binary? ⇒ Boolean
Returns true if this file is a binary file
314 315 316 |
# File 'lib/git/diff.rb', line 314 def binary? !!@binary end |
#blob(type = :dst) ⇒ Git::Object::Blob?
Returns the blob object for this file
332 333 334 335 336 337 338 |
# File 'lib/git/diff.rb', line 332 def blob(type = :dst) if type == :src && !NIL_BLOB_REGEXP.match(@src) @base.object(@src) elsif !NIL_BLOB_REGEXP.match(@dst) @base.object(@dst) end end |