Class: Git::Status::StatusFile
- Inherits:
-
Object
- Object
- Git::Status::StatusFile
- Defined in:
- lib/git/status.rb
Overview
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.
Instance Attribute Summary collapse
-
#mode_index ⇒ String?
readonly
The file mode recorded in the index.
-
#mode_repo ⇒ String?
readonly
The file mode recorded in HEAD.
-
#path ⇒ String
readonly
The repository-relative file path.
-
#sha_index ⇒ String?
readonly
The SHA of the index version of this file.
-
#sha_repo ⇒ String?
readonly
The SHA of the HEAD version of this file.
-
#stage ⇒ String?
readonly
The merge stage for this file.
-
#type ⇒ String?
readonly
The change type for this file.
-
#untracked ⇒ Boolean?
readonly
Whether this file is untracked.
Instance Method Summary collapse
-
#blob(type = :index) ⇒ Git::Object::Blob?
Return a blob object for the index or repo version of this file.
-
#initialize(base, hash) ⇒ StatusFile
constructor
Initialize a new StatusFile with the given git object and data hash.
Constructor Details
#initialize(base, hash) ⇒ StatusFile
Initialize a new StatusFile with the given git object and data hash
246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/git/status.rb', line 246 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 |
Instance Attribute Details
#mode_index ⇒ String? (readonly)
The file mode recorded in the index
218 219 220 |
# File 'lib/git/status.rb', line 218 def mode_index @mode_index end |
#mode_repo ⇒ String? (readonly)
The file mode recorded in HEAD
223 224 225 |
# File 'lib/git/status.rb', line 223 def mode_repo @mode_repo end |
#path ⇒ String (readonly)
The repository-relative file path
201 202 203 |
# File 'lib/git/status.rb', line 201 def path @path end |
#sha_index ⇒ String? (readonly)
The SHA of the index version of this file
228 229 230 |
# File 'lib/git/status.rb', line 228 def sha_index @sha_index end |
#sha_repo ⇒ String? (readonly)
The SHA of the HEAD version of this file
233 234 235 |
# File 'lib/git/status.rb', line 233 def sha_repo @sha_repo end |
#stage ⇒ String? (readonly)
The merge stage for this file
213 214 215 |
# File 'lib/git/status.rb', line 213 def stage @stage end |
#type ⇒ String? (readonly)
The change type for this file
207 208 209 |
# File 'lib/git/status.rb', line 207 def type @type end |
#untracked ⇒ Boolean? (readonly)
Whether this file is untracked
238 239 240 |
# File 'lib/git/status.rb', line 238 def untracked @untracked end |
Instance Method Details
#blob(type = :index) ⇒ Git::Object::Blob?
Return a blob object for the index or repo version of this file
266 267 268 269 |
# File 'lib/git/status.rb', line 266 def blob(type = :index) sha = type == :repo ? sha_repo : (sha_index || sha_repo) @base.object(sha) if sha end |