Class: RubyGit::Status::UnmergedEntry
- Defined in:
- lib/ruby_git/status/unmerged_entry.rb
Overview
Represents an unmerged file in git status
Constant Summary collapse
- CONFLICT_TYPES =
Maps the change code to a conflict type symbol
{ 'DD' => :both_deleted, 'AU' => :added_by_us, 'UD' => :deleted_by_them, 'UA' => :added_by_them, 'DU' => :deleted_by_us, 'AA' => :both_added, 'UU' => :both_modified }.freeze
Constants inherited from Entry
Entry::RENAME_OPERATIONS, Entry::STATUS_CODES
Instance Attribute Summary collapse
-
#base_mode ⇒ Integer
readonly
The mode of the file in the base.
-
#base_sha ⇒ String
readonly
The SHA of the file in the base.
-
#conflict_type ⇒ Symbol
readonly
The type of merge conflict.
-
#our_mode ⇒ Integer
readonly
The mode of the file in our branch.
-
#our_sha ⇒ String
readonly
The SHA of the file in our branch.
-
#path ⇒ String
readonly
The path of the file.
-
#submodule_status ⇒ SubmoduleStatus?
readonly
The submodule status if the entry is a submodule or nil.
-
#their_mode ⇒ Integer
readonly
The mode of the file in their branch.
-
#their_sha ⇒ String
readonly
The SHA of the file in their branch.
-
#worktree_mode ⇒ Integer
readonly
The mode of the file in the worktree.
Class Method Summary collapse
-
.conflict_code_to_type(code) ⇒ Symbol
Convert conflict code to a symbol.
-
.parse(line) ⇒ RubyGit::Status::UnmergedEntry
Parse an unmerged change line of git status output.
Instance Method Summary collapse
-
#initialize(conflict_type:, submodule_status:, base_mode:, our_mode:, their_mode:, worktree_mode:, base_sha:, our_sha:, their_sha:, path:) ⇒ UnmergedEntry
constructor
Initialize a new unmerged entry.
-
#unmerged? ⇒ Boolean
Does the entry represent a merge conflict?.
Methods inherited from Entry
#fully_staged?, #ignored?, #index_status, rename_operation_to_symbol, #staged?, status_to_symbol, #unstaged?, #untracked?, #worktree_status
Constructor Details
#initialize(conflict_type:, submodule_status:, base_mode:, our_mode:, their_mode:, worktree_mode:, base_sha:, our_sha:, their_sha:, path:) ⇒ UnmergedEntry
Initialize a new unmerged entry
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 216 def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists conflict_type:, submodule_status:, base_mode:, our_mode:, their_mode:, worktree_mode:, base_sha:, our_sha:, their_sha:, path: ) super(path) @conflict_type = conflict_type @submodule_status = submodule_status @base_mode = base_mode @our_mode = our_mode @their_mode = their_mode @worktree_mode = worktree_mode @base_sha = base_sha @our_sha = our_sha @their_sha = their_sha @path = path end |
Instance Attribute Details
#base_mode ⇒ Integer (readonly)
The mode of the file in the base
47 48 49 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 47 def base_mode @base_mode end |
#base_sha ⇒ String (readonly)
The SHA of the file in the base
95 96 97 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 95 def base_sha @base_sha end |
#conflict_type ⇒ Symbol (readonly)
The type of merge conflict
23 24 25 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 23 def conflict_type @conflict_type end |
#our_mode ⇒ Integer (readonly)
The mode of the file in our branch
59 60 61 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 59 def our_mode @our_mode end |
#our_sha ⇒ String (readonly)
The SHA of the file in our branch
107 108 109 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 107 def our_sha @our_sha end |
#path ⇒ String (readonly)
The path of the file
131 132 133 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 131 def path @path end |
#submodule_status ⇒ SubmoduleStatus? (readonly)
The submodule status if the entry is a submodule or nil
35 36 37 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 35 def submodule_status @submodule_status end |
#their_mode ⇒ Integer (readonly)
The mode of the file in their branch
71 72 73 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 71 def their_mode @their_mode end |
#their_sha ⇒ String (readonly)
The SHA of the file in their branch
119 120 121 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 119 def their_sha @their_sha end |
#worktree_mode ⇒ Integer (readonly)
The mode of the file in the worktree
83 84 85 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 83 def worktree_mode @worktree_mode end |
Class Method Details
.conflict_code_to_type(code) ⇒ Symbol
Convert conflict code to a symbol
185 186 187 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 185 def self.conflict_code_to_type(code) CONFLICT_TYPES[code] || :unknown end |
.parse(line) ⇒ RubyGit::Status::UnmergedEntry
Parse an unmerged change line of git status output
The line is expected to be in porcelain v2 format with NUL terminators.
The format is as follows:
u
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 149 def self.parse(line) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength tokens = line.split(' ', 11) new( conflict_type: conflict_code_to_type(tokens[1]), submodule_status: SubmoduleStatus.parse(tokens[2]), base_mode: Integer(tokens[3], 8), our_mode: Integer(tokens[4], 8), their_mode: Integer(tokens[5], 8), worktree_mode: Integer(tokens[6], 8), base_sha: tokens[7], our_sha: tokens[8], their_sha: tokens[9], path: tokens[10] ) end |
Instance Method Details
#unmerged? ⇒ Boolean
Does the entry represent a merge conflict?
- Merge conflicts are not considered untracked, staged or unstaged
245 |
# File 'lib/ruby_git/status/unmerged_entry.rb', line 245 def unmerged? = true |