Class: Git::Commands::Revert::Start Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/revert/start.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-revert/2.53.0

Implements git revert to create commits that undo prior changes

Given one or more existing commits, reverts the changes introduced by those commits and records new commits that reverse them. This requires the working tree to be clean.

Examples:

Revert the most recent commit

revert = Git::Commands::Revert::Start.new(execution_context)
revert.call('HEAD')

Revert a specific commit without committing

revert.call('abc123', no_commit: true)

Revert a range of commits

revert.call('HEAD~3..HEAD~1')

Revert a merge commit specifying the mainline parent

revert.call('abc123', mainline: 1)

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(*commit, **options) ⇒ Git::CommandLineResult

Execute the git revert command

Parameters:

  • commit (Array<String>)

    one or more commit SHAs, refs, or rev ranges to revert

  • options (Hash)

    command options

Options Hash (**options):

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

    open the editor for the commit message (--edit)

    Alias: :e

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

    suppress the editor for the commit message (--no-edit)

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

    apply changes to index and working tree without committing

    Alias: :n

  • :mainline (Integer, String) — default: nil

    parent number (starting from 1) identifying the mainline when reverting a merge commit

    Alias: :m

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

    add a Signed-off-by trailer to the commit message (--signoff)

    Alias: :s

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

    suppress the Signed-off-by trailer (--no-signoff)

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

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

    When true, uses the default key. When a String, uses the specified key ID. Alias: :S

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

    disable GPG signing (--no-gpg-sign)

  • :cleanup (String) — default: nil

    commit message cleanup mode

    Accepted values include strip, whitespace, verbatim, scissors, and default. Emits --cleanup=<mode>.

  • :strategy (String) — default: nil

    merge strategy to use (e.g., 'ort', 'recursive', 'resolve')

    Emits --strategy=<strategy>.

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

    pass option(s) to the merge strategy (e.g., 'ours', 'theirs')

    Can be a single value or an array for multiple -X flags. Emits --strategy-option=<option>. Alias: :X

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

    allow rerere to update the index with the auto-resolved conflict result (--rerere-autoupdate)

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

    prevent rerere from auto-updating the index (--no-rerere-autoupdate)

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

    use compact reference format in the revert commit message instead of the full object name

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/revert/start.rb', line 73