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 |
# File 'lib/git/repository/committing.rb', line 75 def commit(, opts = {}) opts = (opts) 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.
127 128 129 |
# File 'lib/git/repository/committing.rb', line 127 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.
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/git/repository/committing.rb', line 163 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.
217 218 219 |
# File 'lib/git/repository/committing.rb', line 217 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
184 185 186 |
# File 'lib/git/repository/committing.rb', line 184 def write_tree Git::Commands::WriteTree.new(@execution_context).call.stdout end |