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
292 293 294 295 296 297 298 299 300 301 |
# File 'lib/git/diff.rb', line 292 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
265 266 267 |
# File 'lib/git/diff.rb', line 265 def dst @dst end |
#mode ⇒ String
The file mode
253 254 255 |
# File 'lib/git/diff.rb', line 253 def mode @mode end |
#patch ⇒ String?
The raw diff patch text for this file
241 242 243 |
# File 'lib/git/diff.rb', line 241 def patch @patch end |
#path ⇒ String?
The file path relative to the repository root
247 248 249 |
# File 'lib/git/diff.rb', line 247 def path @path end |
#src ⇒ String
The source (pre-change) blob SHA
259 260 261 |
# File 'lib/git/diff.rb', line 259 def src @src end |
#type ⇒ String
The type of change
271 272 273 |
# File 'lib/git/diff.rb', line 271 def type @type end |
Instance Method Details
#binary? ⇒ Boolean
Returns true if this file is a binary file
310 311 312 |
# File 'lib/git/diff.rb', line 310 def binary? !!@binary end |
#blob(type = :dst) ⇒ Git::Object::Blob?
Returns the blob object for this file
328 329 330 331 332 333 334 |
# File 'lib/git/diff.rb', line 328 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 |