Module: Git::Repository::Staging
- Included in:
- Git::Repository
- Defined in:
- lib/git/repository/staging.rb
Overview
Facade methods for staging-area operations: adding, resetting, removing, and cleaning files
Included by Git::Repository.
Instance Method Summary collapse
-
#add(paths = '.', **options) ⇒ String
Update the index with the current content found in the working tree.
-
#clean(opts = {}) ⇒ String
Remove untracked files from the working tree.
-
#ignored_files ⇒ Array<String>
List the files in the working tree that are ignored by git.
-
#reset(commitish = nil, **options) ⇒ String
Reset the current HEAD to a specified state.
-
#rm(path = '.', opts = {}) ⇒ String
Remove file(s) from the working tree and the index.
Instance Method Details
#add(paths = '.', **options) ⇒ String
Update the index with the current content found in the working tree
55 56 57 58 |
# File 'lib/git/repository/staging.rb', line 55 def add(paths = '.', **) SharedPrivate.assert_valid_opts!(ADD_ALLOWED_OPTS, **) Git::Commands::Add.new(@execution_context).call(*Array(paths), **).stdout end |
#clean(opts = {}) ⇒ String
Remove untracked files from the working tree
218 219 220 221 222 |
# File 'lib/git/repository/staging.rb', line 218 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>
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.
240 241 242 243 244 |
# File 'lib/git/repository/staging.rb', line 240 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 |
#reset(commitish = nil, **options) ⇒ String
Reset the current HEAD to a specified state
88 89 90 91 |
# File 'lib/git/repository/staging.rb', line 88 def reset(commitish = nil, **) SharedPrivate.assert_valid_opts!(RESET_ALLOWED_OPTS, **) Git::Commands::Reset.new(@execution_context).call(commitish, **).stdout end |
#rm(path = '.', opts = {}) ⇒ String
Remove file(s) from the working tree and the index
155 156 157 158 |
# File 'lib/git/repository/staging.rb', line 155 def rm(path = '.', opts = {}) SharedPrivate.assert_valid_opts!(RM_ALLOWED_OPTS, **opts) Git::Commands::Rm.new(@execution_context).call(*Array(path), **opts).stdout end |