Module: Git::Repository::Committing Private
- Included in:
- Git::Repository
- Defined in:
- lib/git/repository/committing.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 committing operations: recording commits, manipulating tree objects, and building commit objects outside the working tree
Included by Git::Repository.
Instance Method Summary collapse
-
#commit(message, opts = {}) ⇒ String
private
Record staged changes as a new commit.
-
#commit_all(message, opts = {}) ⇒ String
private
Commit all modified tracked files without explicitly staging them first.
-
#commit_tree(tree = nil, opts = {}) ⇒ String
private
Create a commit object from a tree SHA without moving HEAD.
-
#write_and_commit_tree(opts = {}) ⇒ String
private
Write the current index to a tree object and immediately commit it.
-
#write_tree ⇒ String
private
Write the current index to a tree object in the object store.
Instance Method Details
#commit(message, 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.
Record staged changes as a new commit
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/git/repository/committing.rb', line 75 def commit(, opts = {}) opts = opts.dup if opts.key?(:add_all) Git::Deprecation.warn('The :add_all option for #commit is deprecated, use :all instead') opts[:all] = opts.delete(:add_all) end SharedPrivate.assert_valid_opts!(COMMIT_ALLOWED_OPTS, **opts) call_opts = { no_edit: true } call_opts[:message] = if Git::Commands::Commit.new(@execution_context).call(**call_opts, **opts).stdout end |
#commit_all(message, 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.
Commit all modified tracked files without explicitly staging them first
Equivalent to calling #commit with all: true merged into opts.
132 133 134 |
# File 'lib/git/repository/committing.rb', line 132 def commit_all(, opts = {}) commit(, opts.merge(all: true)) end |
#commit_tree(tree = 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.
Create a commit object from a tree SHA without moving HEAD
Unlike #commit, this does not read the index; it directly wraps
git commit-tree.
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/git/repository/committing.rb', line 168 def commit_tree(tree = nil, opts = {}) # rubocop:disable Metrics/AbcSize SharedPrivate.assert_valid_opts!(COMMIT_TREE_ALLOWED_OPTS, **opts) opts = opts.dup opts[:p] = opts.delete(:parents) if opts.key?(:parents) opts[:p] = opts.delete(:parent) if opts.key?(:parent) opts[:m] = opts.delete(:message) if opts.key?(:message) opts[:m] = "commit tree #{tree}" unless opts[:m] Git::Commands::CommitTree.new(@execution_context).call(tree, **opts).stdout end |
#write_and_commit_tree(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.
Write the current index to a tree object and immediately commit it
Combines #write_tree and #commit_tree in a single call.
222 223 224 |
# File 'lib/git/repository/committing.rb', line 222 def write_and_commit_tree(opts = {}) commit_tree(write_tree, opts) end |
#write_tree ⇒ 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.
Write the current index to a tree object in the object store
189 190 191 |
# File 'lib/git/repository/committing.rb', line 189 def write_tree Git::Commands::WriteTree.new(@execution_context).call.stdout end |