Module: Git::Repository::Staging Private
- Included in:
- Git::Repository
- Defined in:
- lib/git/repository/staging.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 staging-area operations: adding, resetting, moving, removing, and cleaning files
Included by Git::Repository.
Instance Method Summary collapse
-
#add(paths = '.', **options) ⇒ String
private
Update the index with the current content found in the working tree.
-
#apply(file) ⇒ String?
private
Apply a patch file to the working tree.
-
#apply_mail(file) ⇒ String?
private
Apply a series of patches from a mailbox file to the current branch.
-
#clean(opts = {}) ⇒ String
private
Remove untracked files from the working tree.
-
#ignored_files ⇒ Array<String>
private
List the files in the working tree that are ignored by git.
-
#mv(source, destination, options = {}) ⇒ String
private
Move or rename a file, directory, or symlink in the working tree.
-
#read_tree(treeish, opts = {}) ⇒ String
private
Read tree information into the index.
-
#reset(commitish = nil, opts = {}) ⇒ String
private
Reset the current HEAD to a specified state.
-
#rm(path = '.', opts = {}) ⇒ String
(also: #remove)
private
Remove file(s) from the working tree and the index.
Instance Method Details
#add(paths = '.', **options) ⇒ 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.
Update the index with the current content found in the working tree
59 60 61 62 |
# File 'lib/git/repository/staging.rb', line 59 def add(paths = '.', **) SharedPrivate.assert_valid_opts!(ADD_ALLOWED_OPTS, **) Git::Commands::Add.new(@execution_context).call(*Array(paths), **).stdout end |
#apply(file) ⇒ 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.
Apply a patch file to the working tree
Reads the unified diff in file and applies it to the working tree via
git apply. If file does not exist, the method returns nil without
calling git — preserving the 4.x Git::Base#apply no-op contract.
112 113 114 115 116 |
# File 'lib/git/repository/staging.rb', line 112 def apply(file) return unless File.exist?(file) Git::Commands::Apply.new(@execution_context).call(file, chdir: @execution_context.git_work_dir).stdout end |
#apply_mail(file) ⇒ 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.
If a patch fails to apply, the git am session is left in progress
until the caller continues, skips, or aborts it. The patches applied
before it are already committed on the current branch; aborting the
session removes them again.
Apply a series of patches from a mailbox file to the current branch
Reads the mbox-format file in file and applies the patches via
git am. If file does not exist, the method returns nil without
calling git — preserving the 4.x Git::Base#apply_mail no-op contract.
140 141 142 143 144 |
# File 'lib/git/repository/staging.rb', line 140 def apply_mail(file) return unless File.exist?(file) Git::Commands::Am::Apply.new(@execution_context).call(file, chdir: @execution_context.git_work_dir).stdout end |
#clean(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.
Remove untracked files from the working tree
353 354 355 356 |
# File 'lib/git/repository/staging.rb', line 353 def clean(opts = {}) SharedPrivate.assert_valid_opts!(CLEAN_ALLOWED_OPTS, **opts) Git::Commands::Clean.new(@execution_context).call(**opts).stdout end |
#ignored_files ⇒ 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.
List the files in the working tree that are ignored by git
Runs git ls-files --others --ignored --exclude-standard and returns the
ignored files as repository-relative paths.
374 375 376 377 378 |
# File 'lib/git/repository/staging.rb', line 374 def ignored_files Git::Commands::LsFiles.new(@execution_context).call( others: true, ignored: true, exclude_standard: true ).stdout.split("\n").map { |f| Private.unescape_quoted_path(f) } end |
#mv(source, destination, options = {}) ⇒ 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.
Move or rename a file, directory, or symlink in the working tree
Updates the index after successful completion, but the change must still be committed.
295 296 297 298 |
# File 'lib/git/repository/staging.rb', line 295 def mv(source, destination, = {}) SharedPrivate.assert_valid_opts!(MV_ALLOWED_OPTS, **) Git::Commands::Mv.new(@execution_context).call(*Array(source), destination, verbose: true, **).stdout end |
#read_tree(treeish, 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.
Read tree information into the index
Reads the named tree object into the index. This is a low-level plumbing operation used to stage the contents of a tree without updating the working tree. Typically called before Branching#checkout_index or as part of custom merge flows.
177 178 179 180 |
# File 'lib/git/repository/staging.rb', line 177 def read_tree(treeish, opts = {}) SharedPrivate.assert_valid_opts!(READ_TREE_ALLOWED_OPTS, **opts) Git::Commands::ReadTree.new(@execution_context).call(treeish, **opts).stdout end |
#reset(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.
Reset the current HEAD to a specified state
90 91 92 93 |
# File 'lib/git/repository/staging.rb', line 90 def reset(commitish = nil, opts = {}) SharedPrivate.assert_valid_opts!(RESET_ALLOWED_OPTS, **opts) Git::Commands::Reset.new(@execution_context).call(commitish, **opts).stdout end |
#rm(path = '.', opts = {}) ⇒ String Also known as: remove
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.
Remove file(s) from the working tree and the index
244 245 246 247 |
# File 'lib/git/repository/staging.rb', line 244 def rm(path = '.', opts = {}) SharedPrivate.assert_valid_opts!(RM_ALLOWED_OPTS, **opts) Git::Commands::Rm.new(@execution_context).call(*Array(path), **opts).stdout end |