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.
-
#reset_hard(commitish = nil, opts = {}) ⇒ String
deprecated
private
Deprecated.
Use #reset with
hard: trueinstead -
#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.
144 145 146 147 148 |
# File 'lib/git/repository/staging.rb', line 144 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.
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.
167 168 169 170 171 |
# File 'lib/git/repository/staging.rb', line 167 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
385 386 387 388 389 |
# File 'lib/git/repository/staging.rb', line 385 def clean(opts = {}) opts = Private.(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.
407 408 409 410 411 |
# File 'lib/git/repository/staging.rb', line 407 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.
322 323 324 325 |
# File 'lib/git/repository/staging.rb', line 322 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.
204 205 206 207 |
# File 'lib/git/repository/staging.rb', line 204 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 |
#reset_hard(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.
Use #reset with hard: true instead
Reset the current HEAD to a specified state with --hard
119 120 121 122 123 124 125 |
# File 'lib/git/repository/staging.rb', line 119 def reset_hard(commitish = nil, opts = {}) Git::Deprecation.warn( 'Git::Repository::Staging#reset_hard is deprecated and will be removed in a future version. ' \ 'Use #reset(commitish, hard: true) instead.' ) reset(commitish, **opts, hard: true) 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
271 272 273 274 |
# File 'lib/git/repository/staging.rb', line 271 def rm(path = '.', opts = {}) SharedPrivate.assert_valid_opts!(RM_ALLOWED_OPTS, **opts) Git::Commands::Rm.new(@execution_context).call(*Array(path), **opts).stdout end |