Class: Git::DiffFileRawInfo Private
- Inherits:
-
Data
- Object
- Data
- Git::DiffFileRawInfo
- Defined in:
- lib/git/diff_file_raw_info.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Immutable value object representing status info for a single file from git raw diff output
Contains the source and destination file references, change status, similarity percentage (for renames/copies), and line change statistics.
Work in progress; this class is internal for now and may be made public in a future release.
Instance Attribute Summary collapse
-
#binary ⇒ Boolean
readonly
Whether this is a binary file.
-
#deletions ⇒ Integer
readonly
Number of lines deleted.
-
#dst ⇒ FileRef?
readonly
The destination file reference, or nil for deleted files.
-
#insertions ⇒ Integer
readonly
Number of lines inserted.
-
#similarity ⇒ Integer?
readonly
Similarity percentage for renames/copies (0-100), nil otherwise.
-
#src ⇒ FileRef?
readonly
The source file reference, or nil for new/added files.
-
#status ⇒ Symbol
readonly
The change status (:added, :modified, :deleted, :renamed, :copied, :type_changed).
Instance Method Summary collapse
-
#added? ⇒ Boolean
private
Check if this file was added.
-
#binary? ⇒ Boolean
private
Check if this is a binary file.
-
#copied? ⇒ Boolean
private
Check if this file was copied.
-
#deleted? ⇒ Boolean
private
Check if this file was deleted.
-
#path ⇒ String
private
Get the primary file path.
-
#renamed? ⇒ Boolean
private
Check if this file was renamed.
-
#src_path ⇒ String?
private
Get the source path (for renames/copies).
Instance Attribute Details
#binary ⇒ Boolean (readonly)
Returns whether this is a binary file.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#deletions ⇒ Integer (readonly)
Returns number of lines deleted.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#dst ⇒ FileRef? (readonly)
Returns the destination file reference, or nil for deleted files.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#insertions ⇒ Integer (readonly)
Returns number of lines inserted.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#similarity ⇒ Integer? (readonly)
Returns similarity percentage for renames/copies (0-100), nil otherwise.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#src ⇒ FileRef? (readonly)
Returns the source file reference, or nil for new/added files.
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
#status ⇒ Symbol (readonly)
Returns the change status (:added, :modified, :deleted, :renamed, :copied, :type_changed).
69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/git/diff_file_raw_info.rb', line 69 DiffFileRawInfo = Data.define(:src, :dst, :status, :similarity, :insertions, :deletions, :binary) do # Get the primary file path # # Returns the destination path if it exists, otherwise the source path. # This is the "current" or "canonical" path for the file. # # @return [String] the file path # def path dst&.path || src&.path end # Get the source path (for renames/copies) # # @return [String, nil] the source path, or nil if file was added # def src_path src&.path end # Check if this is a binary file # # @return [Boolean] true if the file is binary # def binary? binary end # Check if this file was renamed # # @return [Boolean] # def renamed? status == :renamed end # Check if this file was copied # # @return [Boolean] # def copied? status == :copied end # Check if this file was added # # @return [Boolean] # def added? status == :added end # Check if this file was deleted # # @return [Boolean] # def deleted? status == :deleted end end |
Instance Method Details
#added? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this file was added
117 118 119 |
# File 'lib/git/diff_file_raw_info.rb', line 117 def added? status == :added end |
#binary? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this is a binary file
93 94 95 |
# File 'lib/git/diff_file_raw_info.rb', line 93 def binary? binary end |
#copied? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this file was copied
109 110 111 |
# File 'lib/git/diff_file_raw_info.rb', line 109 def copied? status == :copied end |
#deleted? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this file was deleted
125 126 127 |
# File 'lib/git/diff_file_raw_info.rb', line 125 def deleted? status == :deleted end |
#path ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the primary file path
Returns the destination path if it exists, otherwise the source path. This is the "current" or "canonical" path for the file.
77 78 79 |
# File 'lib/git/diff_file_raw_info.rb', line 77 def path dst&.path || src&.path end |
#renamed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if this file was renamed
101 102 103 |
# File 'lib/git/diff_file_raw_info.rb', line 101 def renamed? status == :renamed end |
#src_path ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the source path (for renames/copies)
85 86 87 |
# File 'lib/git/diff_file_raw_info.rb', line 85 def src_path src&.path end |