Module: Git::Configuring Private
- Included in:
- Git, Repository
- Defined in:
- lib/git/configuring.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.
Mixin that adds structured git config read and write operations
Include or extend this module to gain the full suite of config_* methods.
The including/extending class must implement two private methods:
- #execution_context — returns a
Git::ExecutionContextused to run commands - #assert_valid_scope! — raises
ArgumentErrorif a requested scope is not valid in this context (e.g.,:localis not valid without a repository)
Read methods that return ConfigEntryInfo objects merge
show_scope: true, show_origin: true, null: true into the options so that
every returned entry carries its full provenance. Two exceptions apply:
#config_get_urlmatch merges only show_scope: true, null: true because
git does not support --show-origin with --get-urlmatch (those entries
always have origin: nil); #config_get_colorbool returns a plain String
and does not use these output-format options at all.
Read Operations collapse
-
#config_get(name, value_regex = nil, **options) ⇒ Git::ConfigEntryInfo?
private
Retrieve a single config entry by key name.
-
#config_get_all(name, value_regex = nil, **options) ⇒ Array<Git::ConfigEntryInfo>
private
Retrieve all values for a multi-valued config key.
-
#config_get_colorbool(name, stdout_is_tty = nil, **options) ⇒ String
private
Query whether color output is enabled for a given config slot.
-
#config_get_regexp(name_regex, value_regex = nil, **options) ⇒ Array<Git::ConfigEntryInfo>
private
Retrieve all config entries whose key matches a regular expression.
-
#config_get_urlmatch(name, url, **options) ⇒ Array<Git::ConfigEntryInfo>
private
Retrieve config entries whose URL pattern matches a given URL.
-
#config_list(**options) ⇒ Array<Git::ConfigEntryInfo>
private
List all visible config entries.
Write Operations collapse
-
#config_add(name, value, **options) ⇒ nil
private
Append a value to a multi-valued config key.
-
#config_remove_section(name, **options) ⇒ nil
private
Remove an entire config section.
-
#config_rename_section(old_name, new_name, **options) ⇒ nil
private
Rename a config section.
-
#config_replace_all(name, value, value_regex = nil, **options) ⇒ nil
private
Replace all values matching a key and optional value regex.
-
#config_set(name, value, **options) ⇒ nil
private
Set a config entry to a new value.
-
#config_unset(name, value_regex = nil, **options) ⇒ nil
private
Remove a config entry.
-
#config_unset_all(name, value_regex = nil, **options) ⇒ nil
private
Remove all config entries for a key.
Instance Method Details
#config_add(name, value, **options) ⇒ nil
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.
395 396 397 398 399 400 401 |
# File 'lib/git/configuring.rb', line 395 def config_add(name, value, **) Private.assert_valid_opts!(CONFIG_ADD_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::Add.new(execution_context) cmd.call(name, value, **) nil end |
#config_get(name, value_regex = nil, **options) ⇒ Git::ConfigEntryInfo?
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.
Retrieve a single config entry by key name
Wraps git config --get --show-scope --show-origin --null.
91 92 93 94 95 96 97 98 |
# File 'lib/git/configuring.rb', line 91 def config_get(name, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_GET_ALLOWED_OPTS, **) assert_valid_scope!(**) = .merge(show_scope: true, show_origin: true, null: true) cmd = Git::Commands::ConfigOptionSyntax::Get.new(execution_context) output = cmd.call(name, value_regex, **).stdout Git::Parsers::ConfigEntry.parse_get(name, output) end |
#config_get_all(name, value_regex = nil, **options) ⇒ Array<Git::ConfigEntryInfo>
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.
Retrieve all values for a multi-valued config key
Wraps git config --get-all --show-scope --show-origin --null.
142 143 144 145 146 147 148 149 |
# File 'lib/git/configuring.rb', line 142 def config_get_all(name, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_GET_ALL_ALLOWED_OPTS, **) assert_valid_scope!(**) = .merge(show_scope: true, show_origin: true, null: true) cmd = Git::Commands::ConfigOptionSyntax::GetAll.new(execution_context) output = cmd.call(name, value_regex, **).stdout Git::Parsers::ConfigEntry.parse_get_all(name, output) end |
#config_get_colorbool(name, stdout_is_tty = nil, **options) ⇒ 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.
192 193 194 195 196 197 |
# File 'lib/git/configuring.rb', line 192 def config_get_colorbool(name, stdout_is_tty = nil, **) Private.assert_valid_opts!(CONFIG_GET_COLORBOOL_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::GetColorBool.new(execution_context) cmd.call(name, stdout_is_tty, **).stdout.chomp end |
#config_get_regexp(name_regex, value_regex = nil, **options) ⇒ Array<Git::ConfigEntryInfo>
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.
Retrieve all config entries whose key matches a regular expression
Wraps git config --get-regexp --show-scope --show-origin --null.
241 242 243 244 245 246 247 248 |
# File 'lib/git/configuring.rb', line 241 def config_get_regexp(name_regex, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_GET_REGEXP_ALLOWED_OPTS, **) assert_valid_scope!(**) = .merge(show_scope: true, show_origin: true, null: true) cmd = Git::Commands::ConfigOptionSyntax::GetRegexp.new(execution_context) output = cmd.call(name_regex, value_regex, **).stdout Git::Parsers::ConfigEntry.parse_list(output) end |
#config_get_urlmatch(name, url, **options) ⇒ Array<Git::ConfigEntryInfo>
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.
--show-origin is not supported by git for --get-urlmatch, so the
Git::ConfigEntryInfo entries returned by this method always have
origin: nil.
Retrieve config entries whose URL pattern matches a given URL
Wraps git config --get-urlmatch --show-scope --null.
296 297 298 299 300 301 302 303 |
# File 'lib/git/configuring.rb', line 296 def config_get_urlmatch(name, url, **) Private.assert_valid_opts!(CONFIG_GET_URLMATCH_ALLOWED_OPTS, **) assert_valid_scope!(**) = .merge(show_scope: true, null: true) cmd = Git::Commands::ConfigOptionSyntax::GetUrlmatch.new(execution_context) output = cmd.call(name, url, **).stdout Git::Parsers::ConfigEntry.parse_urlmatch(output) end |
#config_list(**options) ⇒ Array<Git::ConfigEntryInfo>
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.
List all visible config entries
Wraps git config --list --show-scope --show-origin --null.
343 344 345 346 347 348 349 350 |
# File 'lib/git/configuring.rb', line 343 def config_list(**) Private.assert_valid_opts!(CONFIG_LIST_ALLOWED_OPTS, **) assert_valid_scope!(**) = .merge(show_scope: true, show_origin: true, null: true) cmd = Git::Commands::ConfigOptionSyntax::List.new(execution_context) output = cmd.call(**).stdout Git::Parsers::ConfigEntry.parse_list(output) end |
#config_remove_section(name, **options) ⇒ nil
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.
438 439 440 441 442 443 444 |
# File 'lib/git/configuring.rb', line 438 def config_remove_section(name, **) Private.assert_valid_opts!(CONFIG_REMOVE_SECTION_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::RemoveSection.new(execution_context) cmd.call(name, **) nil end |
#config_rename_section(old_name, new_name, **options) ⇒ nil
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.
483 484 485 486 487 488 489 |
# File 'lib/git/configuring.rb', line 483 def config_rename_section(old_name, new_name, **) Private.assert_valid_opts!(CONFIG_RENAME_SECTION_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::RenameSection.new(execution_context) cmd.call(old_name, new_name, **) nil end |
#config_replace_all(name, value, value_regex = nil, **options) ⇒ nil
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.
532 533 534 535 536 537 538 |
# File 'lib/git/configuring.rb', line 532 def config_replace_all(name, value, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_REPLACE_ALL_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(execution_context) cmd.call(name, value, value_regex, **) nil end |
#config_set(name, value, **options) ⇒ nil
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.
579 580 581 582 583 584 585 |
# File 'lib/git/configuring.rb', line 579 def config_set(name, value, **) Private.assert_valid_opts!(CONFIG_SET_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::Set.new(execution_context) cmd.call(name, value, **) nil end |
#config_unset(name, value_regex = nil, **options) ⇒ nil
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.
624 625 626 627 628 629 630 |
# File 'lib/git/configuring.rb', line 624 def config_unset(name, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_UNSET_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::Unset.new(execution_context) cmd.call(name, value_regex, **) nil end |
#config_unset_all(name, value_regex = nil, **options) ⇒ nil
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.
669 670 671 672 673 674 675 |
# File 'lib/git/configuring.rb', line 669 def config_unset_all(name, value_regex = nil, **) Private.assert_valid_opts!(CONFIG_UNSET_ALL_ALLOWED_OPTS, **) assert_valid_scope!(**) cmd = Git::Commands::ConfigOptionSyntax::UnsetAll.new(execution_context) cmd.call(name, value_regex, **) nil end |