class Git::Status::Git::Status::StatusFile
Represents a single fileβs status in the git repository. Each instance holds information about a fileβs state in the index and working tree.
@api public
Attributes
The file mode recorded in the index
@return [String, nil] the octal file mode (e.g. ββ100644β`), or `nil`
The file mode recorded in HEAD
@return [String, nil] the octal file mode (e.g. ββ100644β`), or `nil`
The repository-relative file path
@return [String] the path
The SHA of the index version of this file
@return [String, nil] the SHA-1 hex digest, or βnil` if unavailable
The SHA of the HEAD version of this file
@return [String, nil] the SHA-1 hex digest, or βnil` if unavailable
The merge stage for this file
@return [String, nil] ββ0β` for normal entries, or a non-zero value during
a merge conflict
The change type for this file
@return [String, nil] ββMβ` for modified, `βAβ` for added, `βDβ` for deleted,
or `nil` when not applicable
Whether this file is untracked
@return [Boolean, nil] βtrue` when the file is not tracked by git
Public Class Methods
Source
# File lib/git/status.rb, line 258 def initialize(base, hash) @base = base @path = hash[:path] @type = hash[:type] @stage = hash[:stage] @mode_index = hash[:mode_index] @mode_repo = hash[:mode_repo] @sha_index = hash[:sha_index] @sha_repo = hash[:sha_repo] @untracked = hash[:untracked] end
Initialize a new StatusFile with the given git object and data hash
@param base [Git::Repository] the git object
@param hash [Hash] raw status data for this file
Public Instance Methods
Source
# File lib/git/status.rb, line 278 def blob(type = :index) sha = type == :repo ? sha_repo : (sha_index || sha_repo) @base.object(sha) if sha end
Return a blob object for the index or repo version of this file
@param type [Symbol] β:index` (default) for the index version, or
`:repo` for the HEAD version
@return [Git::Object::Blob, nil] the blob object, or βnil` if no SHA
is available for the requested version