Class: RubyGit::Status::OrdinaryEntry
- Defined in:
- lib/ruby_git/status/ordinary_entry.rb
Overview
Represents an ordinary changed file in git status
Constant Summary
Constants inherited from Entry
Entry::RENAME_OPERATIONS, Entry::STATUS_CODES
Instance Attribute Summary collapse
-
#head_mode ⇒ Integer
readonly
private
The file mode in HEAD.
-
#head_sha ⇒ String
readonly
The SHA of this object in HEAD.
-
#index_mode ⇒ Integer
readonly
private
The file mode in the index.
-
#index_sha ⇒ String
readonly
The SHA of this object in the index.
-
#index_status ⇒ Symbol
readonly
The status in the staging area.
-
#submodule_status ⇒ SubmoduleStatus?
readonly
The submodule status if the entry is a submodule.
-
#worktree_mode ⇒ Integer
readonly
private
The file mode in the worktree.
-
#worktree_status ⇒ Symbol
readonly
The status in the worktree.
Attributes inherited from Entry
Class Method Summary collapse
-
.parse(line) ⇒ RubyGit::Status::OrdinaryEntry
Parse an ordinary change line of git status output.
Instance Method Summary collapse
-
#initialize(path:, index_status:, worktree_status:, submodule_status:, head_mode:, index_mode:, worktree_mode:, head_sha:, index_sha:) ⇒ OrdinaryEntry
constructor
Initialize a new ordinary entry.
-
#staged? ⇒ Boolean
Does the entry have staged changes in the index?.
-
#unstaged? ⇒ Boolean
Does the entry have unstaged changes in the worktree?.
Methods inherited from Entry
#fully_staged?, #ignored?, rename_operation_to_symbol, status_to_symbol, #unmerged?, #untracked?
Constructor Details
#initialize(path:, index_status:, worktree_status:, submodule_status:, head_mode:, index_mode:, worktree_mode:, head_sha:, index_sha:) ⇒ OrdinaryEntry
Initialize a new ordinary entry
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 165 def initialize( # rubocop:disable Metrics/ParameterLists path:, index_status:, worktree_status:, submodule_status:, head_mode:, index_mode:, worktree_mode:, head_sha:, index_sha: ) super(path) @index_status = index_status @worktree_status = worktree_status @submodule_status = submodule_status @worktree_mode = worktree_mode @index_mode = index_mode @head_mode = head_mode @head_sha = head_sha @index_sha = index_sha end |
Instance Attribute Details
#head_mode ⇒ Integer (readonly)
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.
The file mode in HEAD
82 83 84 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 82 def head_mode @head_mode end |
#head_sha ⇒ String (readonly)
The SHA of this object in HEAD
58 59 60 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 58 def head_sha @head_sha end |
#index_mode ⇒ Integer (readonly)
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.
The file mode in the index
94 95 96 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 94 def index_mode @index_mode end |
#index_sha ⇒ String (readonly)
The SHA of this object in the index
70 71 72 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 70 def index_sha @index_sha end |
#index_status ⇒ Symbol (readonly)
The status in the staging area
22 23 24 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 22 def index_status @index_status end |
#submodule_status ⇒ SubmoduleStatus? (readonly)
The submodule status if the entry is a submodule
46 47 48 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 46 def submodule_status @submodule_status end |
#worktree_mode ⇒ Integer (readonly)
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.
The file mode in the worktree
106 107 108 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 106 def worktree_mode @worktree_mode end |
#worktree_status ⇒ Symbol (readonly)
The status in the worktree
34 35 36 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 34 def worktree_status @worktree_status end |
Class Method Details
.parse(line) ⇒ RubyGit::Status::OrdinaryEntry
Parse an ordinary change line of git status output
The line is expected to be in porcelain v2 format with NUL terminators.
The format is as follows:
1
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 124 def self.parse(line) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength tokens = line.split new( index_status: Entry.status_to_symbol(tokens[1][0]), worktree_status: Entry.status_to_symbol(tokens[1][1]), submodule_status: SubmoduleStatus.parse(tokens[2]), head_mode: Integer(tokens[3], 8), index_mode: Integer(tokens[4], 8), worktree_mode: Integer(tokens[5], 8), head_sha: tokens[6], index_sha: tokens[7], path: tokens[8] ) end |
Instance Method Details
#staged? ⇒ Boolean
Does the entry have staged changes in the index?
- An entry can have both staged and unstaged changes
202 203 204 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 202 def staged? index_status != :unmodified end |
#unstaged? ⇒ Boolean
Does the entry have unstaged changes in the worktree?
- An entry can have both staged and unstaged changes
- All untracked entries are considered unstaged
191 192 193 |
# File 'lib/ruby_git/status/ordinary_entry.rb', line 191 def unstaged? worktree_status != :unmodified end |