Module: Git::Repository::Merging Private
- Included in:
- Git::Repository
- Defined in:
- lib/git/repository/merging.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Facade methods for merge operations: merging branches into the current branch, and finding common ancestors between commits
Included by Git::Repository.
Instance Method Summary collapse
-
#conflicts {|file, your_version, their_version| ... } ⇒ Array<String>
deprecated
private
Deprecated.
Use #each_conflict instead
-
#each_conflict {|file, your_version, their_version| ... } ⇒ Array<String>
private
Iterate over files with merge conflicts, yielding conflict details for each.
-
#merge(branch, message = nil, opts = {}) ⇒ String
private
Merge one or more branches into the current branch.
-
#merge_base(*commits, options = {}) ⇒ Array<String>
private
Find common ancestor commit(s) for use in a merge.
-
#revert(commitish = nil, opts = {}) ⇒ String
private
Revert one or more existing commits by creating new commits that undo the changes those commits introduced.
-
#unmerged ⇒ Array<String>
private
Return the paths of files with unresolved merge conflicts.
Instance Method Details
#conflicts {|file, your_version, their_version| ... } ⇒ Array<String>
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.
Use #each_conflict instead
Iterate over files with merge conflicts, yielding conflict details for each
For each unmerged file, the staged content for both sides of the conflict (stage 2 "ours" and stage 3 "theirs") is written to temporary files whose paths are yielded alongside the file path. The temporary files are deleted automatically when the block returns.
246 247 248 249 250 251 252 |
# File 'lib/git/repository/merging.rb', line 246 def conflicts(&) Git::Deprecation.warn( 'Git::Repository#conflicts is deprecated and will be removed in a future version. ' \ 'Use Git::Repository#each_conflict instead.' ) each_conflict(&) end |
#each_conflict {|file, your_version, their_version| ... } ⇒ Array<String>
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.
Iterate over files with merge conflicts, yielding conflict details for each
For each unmerged file, the staged content for both sides of the conflict (stage 2 "ours" and stage 3 "theirs") is written to temporary files whose paths are yielded alongside the file path. The temporary files are deleted automatically when the block returns.
201 202 203 204 205 206 207 208 209 |
# File 'lib/git/repository/merging.rb', line 201 def each_conflict Private.unmerged_paths(@execution_context).each do |file_path| Private.write_staged_file(@execution_context, file_path, 2) do |your_file| Private.write_staged_file(@execution_context, file_path, 3) do |their_file| yield(file_path, your_file.path, their_file.path) end end end end |
#merge(branch, message = nil, opts = {}) ⇒ String
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.
Merge one or more branches into the current branch
The merge commit message may be given by the message positional argument, the
:message option, or the :m option; if more than one is provided, the
precedence is positional argument > :message > :m.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/git/repository/merging.rb', line 84 def merge(branch, = nil, opts = {}) SharedPrivate.assert_valid_opts!(MERGE_ALLOWED_OPTS, **opts) # Dup so callers who reuse the same opts hash are not affected opts = opts.dup # Merge positional message into opts so the rest of the logic is uniform opts[:message] = if # git merge uses -m, not --message; translate the key opts[:m] = opts.delete(:message) if opts.key?(:message) branches = Array(branch).map(&:to_s) Git::Commands::Merge::Start.new(@execution_context).call(*branches, no_edit: true, **opts).stdout end |
#merge_base(*commits, options = {}) ⇒ Array<String>
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.
Find common ancestor commit(s) for use in a merge
141 142 143 144 145 146 |
# File 'lib/git/repository/merging.rb', line 141 def merge_base(*args) opts = args.last.is_a?(Hash) ? args.pop : {} SharedPrivate.assert_valid_opts!(MERGE_BASE_ALLOWED_OPTS, **opts) result = Git::Commands::MergeBase.new(@execution_context).call(*args, **opts) result.stdout.lines.map(&:strip).reject(&:empty?) end |
#revert(commitish = nil, opts = {}) ⇒ String
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.
Revert one or more existing commits by creating new commits that undo the changes those commits introduced
The working tree must be clean before calling this method. By default
the editor is suppressed (--no-edit) so the commit message is taken
from git's default revert message without prompting.
294 295 296 297 298 299 |
# File 'lib/git/repository/merging.rb', line 294 def revert(commitish = nil, opts = {}) commitish = 'HEAD' if commitish.nil? SharedPrivate.assert_valid_opts!(REVERT_ALLOWED_OPTS, **opts) opts = { no_edit: true }.merge(opts) Git::Commands::Revert::Start.new(@execution_context).call(commitish, **opts).stdout end |
#unmerged ⇒ Array<String>
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.
Return the paths of files with unresolved merge conflicts
162 163 164 |
# File 'lib/git/repository/merging.rb', line 162 def unmerged Private.unmerged_paths(@execution_context) end |