Class: Git::Commands::CommitTree Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/commit_tree.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-commit-tree/2.53.0

Implements the git commit-tree command

Creates a new commit object based on the provided tree object and emits the new commit object id on stdout. The log message is provided via -m or -F options; multiple instances of either are concatenated as separate paragraphs.

Examples:

Typical usage

commit_tree = Git::Commands::CommitTree.new(execution_context)
commit_tree.call('abc123', m: 'Initial commit')
commit_tree.call('abc123', p: %w[parent1 parent2], m: 'Merge')
commit_tree.call('abc123', m: 'Signed', gpg_sign: true)

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(tree, **options) ⇒ Git::CommandLineResult

Execute the git commit-tree command

Parameters:

  • tree (String)

    an existing tree object SHA

  • options (Hash)

    command options

Options Hash (**options):

  • :p (String, Array<String>) — default: nil

    parent commit object id(s)

    Each value adds a -p <parent> flag. A commit may have zero or more parents. With exactly one parent it is an ordinary commit; with more than one it is a merge commit. Initial (root) commits have no parents.

  • :gpg_sign (Boolean, String, nil) — default: nil

    sign the commit with GPG (--gpg-sign)

    Pass a key-ID string to select the signing key; pass true to use the committer identity. Alias: :S

  • :no_gpg_sign (Boolean, nil) — default: nil

    countermand commit.gpgSign configuration (--no-gpg-sign)

  • :m (String, Array<String>) — default: nil

    a paragraph in the commit log message

    Can be given more than once; each message becomes its own paragraph.

  • :F (String, Array<String>) — default: nil

    read the commit log message from the given file

    Use "-" to read from standard input. Can be given more than once; each file's content becomes its own paragraph.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (ArgumentError)

    if the tree operand is missing

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/commit_tree.rb', line 49