Class: Git::Commands::ConfigOptionSyntax::ReplaceAll Private

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

Replace all matching values for a config key

Wraps git config --replace-all to replace all entries matching the given key and optional value regex with a new value.

Examples:

Replace all values for a key

cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(lib)
cmd.call('core.autocrlf', 'true')

Replace values matching a pattern

cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(lib)
cmd.call('core.autocrlf', 'true', 'false')

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(name, value, value_regex = nil, **options) ⇒ Git::CommandLineResult

Execute the git config --replace-all command

Parameters:

  • name (String)

    the config key name

  • value (String)

    the new value to set

  • value_regex (String, nil) (defaults to: nil)

    (nil) optional regex to match existing values to replace

  • options (Hash)

    command options

Options Hash (**options):

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

    write to global config (~/.gitconfig)

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

    write to system config

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

    write to repository config (.git/config)

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

    write to worktree config

  • :file (String) — default: nil

    write to the specified file

    Alias: :f

  • :blob (String) — default: nil

    read from the specified blob

  • :comment (String) — default: nil

    append a comment at the end of new or modified lines

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

    treat the value regex as an exact string

  • :type (String) — default: nil

    ensure the value conforms to the given type

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

    unset the previously set type specifier; true emits --no-type

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/config_option_syntax/replace_all.rb', line 59