Class: Git::Status::StatusFile
- Inherits:
-
Object
- Object
- Git::Status::StatusFile
- Defined in:
- lib/git/status.rb
Overview
subclass that does heavy lifting
Instance Attribute Summary collapse
-
#mode_index ⇒ String
The mode of the file in the index.
-
#mode_repo ⇒ String
The mode of the file in the repo.
-
#path ⇒ String
The path of the file relative to the project root directory.
-
#sha_index ⇒ String
The sha of the file in the index.
-
#sha_repo ⇒ String
The sha of the file in the repo.
-
#stage ⇒ String
The stage of the file.
-
#type ⇒ String
The type of change.
-
#untracked ⇒ Boolean
Whether the file is untracked.
Instance Method Summary collapse
- #blob(type = :index)
-
#initialize(base, hash) ⇒ StatusFile
constructor
A new instance of StatusFile.
Constructor Details
#initialize(base, hash) ⇒ StatusFile
Returns a new instance of StatusFile.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/git/status.rb', line 192 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
The mode of the file in the index
155 156 157 |
# File 'lib/git/status.rb', line 155 def mode_index @mode_index end |
#mode_repo ⇒ String
The mode of the file in the repo
162 163 164 |
# File 'lib/git/status.rb', line 162 def mode_repo @mode_repo end |
#path ⇒ String
The path of the file relative to the project root directory
137 138 139 |
# File 'lib/git/status.rb', line 137 def path @path end |
#sha_index ⇒ String
The sha of the file in the index
169 170 171 |
# File 'lib/git/status.rb', line 169 def sha_index @sha_index end |
#sha_repo ⇒ String
The sha of the file in the repo
175 176 177 |
# File 'lib/git/status.rb', line 175 def sha_repo @sha_repo end |
#stage ⇒ String
The stage of the file
- '0': the unmerged state
- '1': the common ancestor (or original) version
- '2': "our version" from the current branch head
- '3': "their version" from the other branch head
190 191 192 |
# File 'lib/git/status.rb', line 190 def stage @stage end |
#type ⇒ String
The type of change
- 'M': modified
- 'A': added
- 'D': deleted
- nil: ???
148 149 150 |
# File 'lib/git/status.rb', line 148 def type @type end |
#untracked ⇒ Boolean
Whether the file is untracked
180 181 182 |
# File 'lib/git/status.rb', line 180 def untracked @untracked end |
Instance Method Details
#blob(type = :index)
204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/git/status.rb', line 204 def blob(type = :index) if type == :repo @base.object(@sha_repo) else begin @base.object(@sha_index) rescue @base.object(@sha_repo) end end end |