git 1.19.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +5 -1
- data/AI_POLICY.md +24 -0
- data/CHANGELOG.md +689 -0
- data/CODE_OF_CONDUCT.md +25 -0
- data/CONTRIBUTING.md +1175 -97
- data/GOVERNANCE.md +106 -0
- data/LICENSE +1 -1
- data/MAINTAINERS.md +17 -4
- data/README.md +476 -320
- data/UPGRADING.md +1138 -0
- data/git.gemspec +124 -36
- data/lib/git/author.rb +39 -7
- data/lib/git/author_info.rb +66 -0
- data/lib/git/branch.rb +615 -65
- data/lib/git/branch_delete_failure.rb +34 -0
- data/lib/git/branch_delete_result.rb +66 -0
- data/lib/git/branch_info.rb +237 -0
- data/lib/git/branches.rb +167 -44
- data/lib/git/command_line/base.rb +247 -0
- data/lib/git/command_line/capturing.rb +308 -0
- data/lib/git/command_line/result.rb +88 -0
- data/lib/git/command_line/streaming.rb +236 -0
- data/lib/git/command_line.rb +52 -0
- data/lib/git/commands/add.rb +139 -0
- data/lib/git/commands/am/abort.rb +43 -0
- data/lib/git/commands/am/apply.rb +263 -0
- data/lib/git/commands/am/continue.rb +43 -0
- data/lib/git/commands/am/quit.rb +43 -0
- data/lib/git/commands/am/retry.rb +49 -0
- data/lib/git/commands/am/show_current_patch.rb +64 -0
- data/lib/git/commands/am/skip.rb +42 -0
- data/lib/git/commands/am.rb +33 -0
- data/lib/git/commands/apply.rb +242 -0
- data/lib/git/commands/archive/list_formats.rb +46 -0
- data/lib/git/commands/archive.rb +145 -0
- data/lib/git/commands/arguments.rb +4521 -0
- data/lib/git/commands/base.rb +502 -0
- data/lib/git/commands/branch/copy.rb +102 -0
- data/lib/git/commands/branch/create.rb +177 -0
- data/lib/git/commands/branch/delete.rb +88 -0
- data/lib/git/commands/branch/list.rb +178 -0
- data/lib/git/commands/branch/move.rb +102 -0
- data/lib/git/commands/branch/set_upstream.rb +86 -0
- data/lib/git/commands/branch/show_current.rb +49 -0
- data/lib/git/commands/branch/unset_upstream.rb +53 -0
- data/lib/git/commands/branch.rb +34 -0
- data/lib/git/commands/cat_file/batch.rb +385 -0
- data/lib/git/commands/cat_file/filtered.rb +105 -0
- data/lib/git/commands/cat_file/raw.rb +271 -0
- data/lib/git/commands/cat_file.rb +49 -0
- data/lib/git/commands/checkout/branch.rb +153 -0
- data/lib/git/commands/checkout/files.rb +116 -0
- data/lib/git/commands/checkout.rb +38 -0
- data/lib/git/commands/checkout_index.rb +106 -0
- data/lib/git/commands/clean.rb +102 -0
- data/lib/git/commands/clone.rb +241 -0
- data/lib/git/commands/commit.rb +273 -0
- data/lib/git/commands/commit_tree.rb +101 -0
- data/lib/git/commands/config_option_syntax/add.rb +86 -0
- data/lib/git/commands/config_option_syntax/get.rb +121 -0
- data/lib/git/commands/config_option_syntax/get_all.rb +118 -0
- data/lib/git/commands/config_option_syntax/get_color.rb +95 -0
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +96 -0
- data/lib/git/commands/config_option_syntax/get_regexp.rb +119 -0
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +111 -0
- data/lib/git/commands/config_option_syntax/list.rb +111 -0
- data/lib/git/commands/config_option_syntax/remove_section.rb +79 -0
- data/lib/git/commands/config_option_syntax/rename_section.rb +83 -0
- data/lib/git/commands/config_option_syntax/replace_all.rb +109 -0
- data/lib/git/commands/config_option_syntax/set.rb +119 -0
- data/lib/git/commands/config_option_syntax/unset.rb +92 -0
- data/lib/git/commands/config_option_syntax/unset_all.rb +94 -0
- data/lib/git/commands/config_option_syntax.rb +56 -0
- data/lib/git/commands/describe.rb +156 -0
- data/lib/git/commands/diff.rb +657 -0
- data/lib/git/commands/diff_files.rb +519 -0
- data/lib/git/commands/diff_index.rb +499 -0
- data/lib/git/commands/fetch.rb +354 -0
- data/lib/git/commands/fsck.rb +138 -0
- data/lib/git/commands/gc.rb +134 -0
- data/lib/git/commands/grep.rb +339 -0
- data/lib/git/commands/init.rb +101 -0
- data/lib/git/commands/log.rb +634 -0
- data/lib/git/commands/ls_files.rb +195 -0
- data/lib/git/commands/ls_remote.rb +161 -0
- data/lib/git/commands/ls_tree.rb +135 -0
- data/lib/git/commands/maintenance/register.rb +77 -0
- data/lib/git/commands/maintenance/run.rb +109 -0
- data/lib/git/commands/maintenance/start.rb +71 -0
- data/lib/git/commands/maintenance/stop.rb +60 -0
- data/lib/git/commands/maintenance/unregister.rb +84 -0
- data/lib/git/commands/maintenance.rb +31 -0
- data/lib/git/commands/merge/abort.rb +44 -0
- data/lib/git/commands/merge/continue.rb +44 -0
- data/lib/git/commands/merge/quit.rb +46 -0
- data/lib/git/commands/merge/start.rb +250 -0
- data/lib/git/commands/merge.rb +28 -0
- data/lib/git/commands/merge_base.rb +91 -0
- data/lib/git/commands/mv.rb +82 -0
- data/lib/git/commands/name_rev.rb +119 -0
- data/lib/git/commands/pull.rb +382 -0
- data/lib/git/commands/push.rb +251 -0
- data/lib/git/commands/read_tree.rb +154 -0
- data/lib/git/commands/remote/add.rb +96 -0
- data/lib/git/commands/remote/get_url.rb +68 -0
- data/lib/git/commands/remote/list.rb +56 -0
- data/lib/git/commands/remote/prune.rb +63 -0
- data/lib/git/commands/remote/remove.rb +52 -0
- data/lib/git/commands/remote/rename.rb +76 -0
- data/lib/git/commands/remote/set_branches.rb +70 -0
- data/lib/git/commands/remote/set_head.rb +89 -0
- data/lib/git/commands/remote/set_url.rb +78 -0
- data/lib/git/commands/remote/set_url_add.rb +70 -0
- data/lib/git/commands/remote/set_url_delete.rb +71 -0
- data/lib/git/commands/remote/show.rb +77 -0
- data/lib/git/commands/remote/update.rb +79 -0
- data/lib/git/commands/remote.rb +42 -0
- data/lib/git/commands/repack.rb +281 -0
- data/lib/git/commands/reset.rb +154 -0
- data/lib/git/commands/rev_parse.rb +304 -0
- data/lib/git/commands/revert/abort.rb +45 -0
- data/lib/git/commands/revert/continue.rb +62 -0
- data/lib/git/commands/revert/quit.rb +47 -0
- data/lib/git/commands/revert/skip.rb +44 -0
- data/lib/git/commands/revert/start.rb +158 -0
- data/lib/git/commands/revert.rb +29 -0
- data/lib/git/commands/rm.rb +113 -0
- data/lib/git/commands/show.rb +632 -0
- data/lib/git/commands/show_ref/exclude_existing.rb +119 -0
- data/lib/git/commands/show_ref/exists.rb +80 -0
- data/lib/git/commands/show_ref/list.rb +149 -0
- data/lib/git/commands/show_ref/verify.rb +122 -0
- data/lib/git/commands/show_ref.rb +42 -0
- data/lib/git/commands/stash/apply.rb +81 -0
- data/lib/git/commands/stash/branch.rb +67 -0
- data/lib/git/commands/stash/clear.rb +43 -0
- data/lib/git/commands/stash/create.rb +60 -0
- data/lib/git/commands/stash/drop.rb +73 -0
- data/lib/git/commands/stash/list.rb +43 -0
- data/lib/git/commands/stash/pop.rb +87 -0
- data/lib/git/commands/stash/push.rb +112 -0
- data/lib/git/commands/stash/show.rb +158 -0
- data/lib/git/commands/stash/store.rb +72 -0
- data/lib/git/commands/stash.rb +38 -0
- data/lib/git/commands/status.rb +174 -0
- data/lib/git/commands/symbolic_ref/delete.rb +72 -0
- data/lib/git/commands/symbolic_ref/read.rb +99 -0
- data/lib/git/commands/symbolic_ref/update.rb +79 -0
- data/lib/git/commands/symbolic_ref.rb +38 -0
- data/lib/git/commands/tag/create.rb +142 -0
- data/lib/git/commands/tag/delete.rb +57 -0
- data/lib/git/commands/tag/list.rb +146 -0
- data/lib/git/commands/tag/verify.rb +71 -0
- data/lib/git/commands/tag.rb +26 -0
- data/lib/git/commands/update_ref/batch.rb +145 -0
- data/lib/git/commands/update_ref/delete.rb +90 -0
- data/lib/git/commands/update_ref/update.rb +103 -0
- data/lib/git/commands/update_ref.rb +42 -0
- data/lib/git/commands/version.rb +60 -0
- data/lib/git/commands/worktree/add.rb +139 -0
- data/lib/git/commands/worktree/list.rb +64 -0
- data/lib/git/commands/worktree/lock.rb +58 -0
- data/lib/git/commands/worktree/management_base.rb +51 -0
- data/lib/git/commands/worktree/move.rb +66 -0
- data/lib/git/commands/worktree/prune.rb +67 -0
- data/lib/git/commands/worktree/remove.rb +63 -0
- data/lib/git/commands/worktree/repair.rb +76 -0
- data/lib/git/commands/worktree/unlock.rb +47 -0
- data/lib/git/commands/worktree.rb +43 -0
- data/lib/git/commands/write_tree.rb +68 -0
- data/lib/git/commands.rb +88 -0
- data/lib/git/config.rb +72 -5
- data/lib/git/config_entry_info.rb +106 -0
- data/lib/git/configuring.rb +795 -0
- data/lib/git/detached_head_info.rb +57 -0
- data/lib/git/diff.rb +437 -86
- data/lib/git/diff_file_numstat_info.rb +31 -0
- data/lib/git/diff_file_patch_info.rb +136 -0
- data/lib/git/diff_file_raw_info.rb +129 -0
- data/lib/git/diff_info.rb +162 -0
- data/lib/git/diff_path_status.rb +107 -0
- data/lib/git/diff_result.rb +34 -0
- data/lib/git/diff_stats.rb +111 -0
- data/lib/git/dirstat_info.rb +102 -0
- data/lib/git/encoding_utils.rb +32 -1
- data/lib/git/errors.rb +285 -0
- data/lib/git/escaped_path.rb +57 -5
- data/lib/git/execution_context/global.rb +31 -0
- data/lib/git/execution_context/repository.rb +151 -0
- data/lib/git/execution_context.rb +559 -0
- data/lib/git/factories.rb +813 -0
- data/lib/git/file_ref.rb +77 -0
- data/lib/git/fsck_object.rb +56 -0
- data/lib/git/fsck_result.rb +132 -0
- data/lib/git/log.rb +306 -90
- data/lib/git/object.rb +563 -141
- data/lib/git/parsers/branch.rb +240 -0
- data/lib/git/parsers/cat_file.rb +111 -0
- data/lib/git/parsers/config_entry.rb +110 -0
- data/lib/git/parsers/diff.rb +792 -0
- data/lib/git/parsers/fsck.rb +144 -0
- data/lib/git/parsers/grep.rb +42 -0
- data/lib/git/parsers/ls_remote.rb +79 -0
- data/lib/git/parsers/ls_tree.rb +58 -0
- data/lib/git/parsers/remote.rb +162 -0
- data/lib/git/parsers/stash.rb +292 -0
- data/lib/git/parsers/status.rb +251 -0
- data/lib/git/parsers/tag.rb +341 -0
- data/lib/git/parsers/worktree.rb +185 -0
- data/lib/git/path_resolver.rb +206 -0
- data/lib/git/remote.rb +165 -12
- data/lib/git/remote_info.rb +203 -0
- data/lib/git/repository/branching.rb +964 -0
- data/lib/git/repository/committing.rb +246 -0
- data/lib/git/repository/context_helpers.rb +293 -0
- data/lib/git/repository/diffing.rb +785 -0
- data/lib/git/repository/inspecting.rb +252 -0
- data/lib/git/repository/logging.rb +410 -0
- data/lib/git/repository/maintenance.rb +65 -0
- data/lib/git/repository/merging.rb +451 -0
- data/lib/git/repository/object_operations.rb +1551 -0
- data/lib/git/repository/remote_operations.rb +984 -0
- data/lib/git/repository/shared_private.rb +120 -0
- data/lib/git/repository/staging.rb +587 -0
- data/lib/git/repository/stashing.rb +623 -0
- data/lib/git/repository/status_operations.rb +249 -0
- data/lib/git/repository/worktree_operations.rb +339 -0
- data/lib/git/repository.rb +484 -2
- data/lib/git/stash.rb +109 -12
- data/lib/git/stash_info.rb +102 -0
- data/lib/git/stashes.rb +169 -26
- data/lib/git/status.rb +308 -122
- data/lib/git/status_file_info.rb +258 -0
- data/lib/git/status_info.rb +189 -0
- data/lib/git/tag_delete_failure.rb +34 -0
- data/lib/git/tag_delete_result.rb +66 -0
- data/lib/git/tag_info.rb +99 -0
- data/lib/git/url.rb +15 -8
- data/lib/git/version.rb +113 -2
- data/lib/git/version_constraint.rb +85 -0
- data/lib/git/worktree.rb +150 -8
- data/lib/git/worktree_info.rb +128 -0
- data/lib/git/worktrees.rb +118 -13
- data/lib/git.rb +632 -234
- metadata +369 -54
- data/.github/stale.yml +0 -25
- data/.github/workflows/continuous_integration.yml +0 -49
- data/.gitignore +0 -10
- data/Dockerfile.changelog-rs +0 -12
- data/Gemfile +0 -5
- data/ISSUE_TEMPLATE.md +0 -15
- data/PULL_REQUEST_TEMPLATE.md +0 -9
- data/RELEASING.md +0 -70
- data/Rakefile +0 -60
- data/lib/git/base/factory.rb +0 -99
- data/lib/git/base.rb +0 -711
- data/lib/git/command_line_result.rb +0 -86
- data/lib/git/failed_error.rb +0 -53
- data/lib/git/git_execute_error.rb +0 -7
- data/lib/git/index.rb +0 -5
- data/lib/git/lib.rb +0 -1328
- data/lib/git/path.rb +0 -31
- data/lib/git/signaled_error.rb +0 -50
- data/lib/git/working_directory.rb +0 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module ConfigOptionSyntax
|
|
8
|
+
# Replace all matching values for a config key
|
|
9
|
+
#
|
|
10
|
+
# Wraps `git config --replace-all` to replace all entries matching the
|
|
11
|
+
# given key and optional value regex with a new value.
|
|
12
|
+
#
|
|
13
|
+
# @example Replace all values for a key
|
|
14
|
+
# cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(lib)
|
|
15
|
+
# cmd.call('core.autocrlf', 'true')
|
|
16
|
+
#
|
|
17
|
+
# @example Replace values matching a pattern
|
|
18
|
+
# cmd = Git::Commands::ConfigOptionSyntax::ReplaceAll.new(lib)
|
|
19
|
+
# cmd.call('core.autocrlf', 'true', 'false')
|
|
20
|
+
#
|
|
21
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-config/2.53.0
|
|
22
|
+
#
|
|
23
|
+
# @see Git::Commands::ConfigOptionSyntax
|
|
24
|
+
#
|
|
25
|
+
# @see https://git-scm.com/docs/git-config git-config documentation
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
class ReplaceAll < Git::Commands::Base
|
|
30
|
+
arguments do
|
|
31
|
+
literal 'config'
|
|
32
|
+
literal '--replace-all'
|
|
33
|
+
|
|
34
|
+
# Write modifiers
|
|
35
|
+
value_option :comment
|
|
36
|
+
|
|
37
|
+
# File-scope options
|
|
38
|
+
flag_option :global
|
|
39
|
+
flag_option :system
|
|
40
|
+
flag_option :local
|
|
41
|
+
flag_option :worktree
|
|
42
|
+
value_option %i[file f]
|
|
43
|
+
value_option :blob
|
|
44
|
+
|
|
45
|
+
# Value matching
|
|
46
|
+
flag_option :fixed_value
|
|
47
|
+
|
|
48
|
+
# Type constraint
|
|
49
|
+
value_option :type, inline: true
|
|
50
|
+
flag_option :no_type
|
|
51
|
+
|
|
52
|
+
# Operands
|
|
53
|
+
end_of_options
|
|
54
|
+
operand :name, required: true
|
|
55
|
+
operand :value, required: true
|
|
56
|
+
operand :value_regex
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @!method call(*, **options)
|
|
60
|
+
#
|
|
61
|
+
# @param options [Hash] command options
|
|
62
|
+
#
|
|
63
|
+
# @option options [Boolean, nil] :global (nil) command option key; see
|
|
64
|
+
# overload docs for the full option list
|
|
65
|
+
#
|
|
66
|
+
# @overload call(name, value, value_regex = nil, **options)
|
|
67
|
+
#
|
|
68
|
+
# Execute the `git config --replace-all` command
|
|
69
|
+
#
|
|
70
|
+
# @param name [String] the config key name
|
|
71
|
+
#
|
|
72
|
+
# @param value [String] the new value to set
|
|
73
|
+
#
|
|
74
|
+
# @param value_regex [String, nil] (nil) optional regex to match existing values to replace
|
|
75
|
+
#
|
|
76
|
+
# @param options [Hash] command options
|
|
77
|
+
#
|
|
78
|
+
# @option options [Boolean, nil] :global (nil) write to global config (`~/.gitconfig`)
|
|
79
|
+
#
|
|
80
|
+
# @option options [Boolean, nil] :system (nil) write to system config
|
|
81
|
+
#
|
|
82
|
+
# @option options [Boolean, nil] :local (nil) write to repository config (`.git/config`)
|
|
83
|
+
#
|
|
84
|
+
# @option options [Boolean, nil] :worktree (nil) write to worktree config
|
|
85
|
+
#
|
|
86
|
+
# @option options [String] :file (nil) write to the specified file
|
|
87
|
+
#
|
|
88
|
+
# Alias: :f
|
|
89
|
+
#
|
|
90
|
+
# @option options [String] :blob (nil) read from the specified blob
|
|
91
|
+
#
|
|
92
|
+
# @option options [String] :comment (nil) append a comment at the end of new or modified lines
|
|
93
|
+
#
|
|
94
|
+
# @option options [Boolean, nil] :fixed_value (nil) treat the value regex as an exact string
|
|
95
|
+
#
|
|
96
|
+
# @option options [String] :type (nil) ensure the value conforms to the given type
|
|
97
|
+
#
|
|
98
|
+
# @option options [Boolean, nil] :no_type (nil) unset the previously set type specifier;
|
|
99
|
+
# `true` emits `--no-type`
|
|
100
|
+
#
|
|
101
|
+
# @return [Git::CommandLine::Result] the result of calling `git config --replace-all`
|
|
102
|
+
#
|
|
103
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
104
|
+
#
|
|
105
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module ConfigOptionSyntax
|
|
8
|
+
# Set a config value
|
|
9
|
+
#
|
|
10
|
+
# Wraps the implicit `git config <name> <value>` set mode to assign
|
|
11
|
+
# a value to a config key, optionally replacing only the entry
|
|
12
|
+
# matching a value regex.
|
|
13
|
+
#
|
|
14
|
+
# @example Set a local config value
|
|
15
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Set.new(lib)
|
|
16
|
+
# cmd.call('user.name', 'Alice')
|
|
17
|
+
#
|
|
18
|
+
# @example Set a global config value
|
|
19
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Set.new(lib)
|
|
20
|
+
# cmd.call('user.name', 'Alice', global: true)
|
|
21
|
+
#
|
|
22
|
+
# @example Set a value with a type constraint
|
|
23
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Set.new(lib)
|
|
24
|
+
# cmd.call('core.bare', 'true', type: 'bool')
|
|
25
|
+
#
|
|
26
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-config/2.53.0
|
|
27
|
+
#
|
|
28
|
+
# @see Git::Commands::ConfigOptionSyntax
|
|
29
|
+
#
|
|
30
|
+
# @see https://git-scm.com/docs/git-config git-config documentation
|
|
31
|
+
#
|
|
32
|
+
# @api private
|
|
33
|
+
#
|
|
34
|
+
class Set < Git::Commands::Base
|
|
35
|
+
arguments do
|
|
36
|
+
literal 'config'
|
|
37
|
+
|
|
38
|
+
# Write modifiers
|
|
39
|
+
flag_option :replace_all
|
|
40
|
+
flag_option :append
|
|
41
|
+
value_option :comment
|
|
42
|
+
|
|
43
|
+
# File-scope options
|
|
44
|
+
flag_option :global
|
|
45
|
+
flag_option :system
|
|
46
|
+
flag_option :local
|
|
47
|
+
flag_option :worktree
|
|
48
|
+
value_option %i[file f]
|
|
49
|
+
value_option :blob
|
|
50
|
+
|
|
51
|
+
# Value matching
|
|
52
|
+
flag_option :fixed_value
|
|
53
|
+
|
|
54
|
+
# Type constraint
|
|
55
|
+
value_option :type, inline: true
|
|
56
|
+
flag_option :no_type
|
|
57
|
+
|
|
58
|
+
# Operands
|
|
59
|
+
end_of_options
|
|
60
|
+
operand :name, required: true
|
|
61
|
+
operand :value, required: true
|
|
62
|
+
operand :value_regex
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @!method call(*, **options)
|
|
66
|
+
#
|
|
67
|
+
# @param options [Hash] command options
|
|
68
|
+
#
|
|
69
|
+
# @option options [Boolean, nil] :replace_all (nil) command option key;
|
|
70
|
+
# see overload docs for the full option list
|
|
71
|
+
#
|
|
72
|
+
# @overload call(name, value, value_regex = nil, **options)
|
|
73
|
+
#
|
|
74
|
+
# Execute the `git config <name> <value>` command
|
|
75
|
+
#
|
|
76
|
+
# @param name [String] the config key name to set
|
|
77
|
+
#
|
|
78
|
+
# @param value [String] the value to assign
|
|
79
|
+
#
|
|
80
|
+
# @param value_regex [String, nil] (nil) optional regex to match the existing value to replace
|
|
81
|
+
#
|
|
82
|
+
# @param options [Hash] command options
|
|
83
|
+
#
|
|
84
|
+
# @option options [Boolean, nil] :replace_all (nil) replace all lines matching the key
|
|
85
|
+
#
|
|
86
|
+
# @option options [Boolean, nil] :append (nil) add a new line without altering existing values
|
|
87
|
+
#
|
|
88
|
+
# @option options [String] :comment (nil) append a comment at the end of new or modified lines
|
|
89
|
+
#
|
|
90
|
+
# @option options [Boolean, nil] :global (nil) write to global config (`~/.gitconfig`)
|
|
91
|
+
#
|
|
92
|
+
# @option options [Boolean, nil] :system (nil) write to system config
|
|
93
|
+
#
|
|
94
|
+
# @option options [Boolean, nil] :local (nil) write to repository config (`.git/config`)
|
|
95
|
+
#
|
|
96
|
+
# @option options [Boolean, nil] :worktree (nil) write to worktree config
|
|
97
|
+
#
|
|
98
|
+
# @option options [String] :file (nil) write to the specified file
|
|
99
|
+
#
|
|
100
|
+
# Alias: :f
|
|
101
|
+
#
|
|
102
|
+
# @option options [String] :blob (nil) read from the specified blob
|
|
103
|
+
#
|
|
104
|
+
# @option options [Boolean, nil] :fixed_value (nil) treat the value regex as an exact string
|
|
105
|
+
#
|
|
106
|
+
# @option options [String] :type (nil) ensure the value conforms to the given type
|
|
107
|
+
#
|
|
108
|
+
# @option options [Boolean, nil] :no_type (nil) unset the previously set type specifier;
|
|
109
|
+
# `true` emits `--no-type`
|
|
110
|
+
#
|
|
111
|
+
# @return [Git::CommandLine::Result] the result of calling `git config`
|
|
112
|
+
#
|
|
113
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
114
|
+
#
|
|
115
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module ConfigOptionSyntax
|
|
8
|
+
# Remove a single config entry
|
|
9
|
+
#
|
|
10
|
+
# Wraps `git config --unset` to remove the entry matching the given
|
|
11
|
+
# key name and optional value regex.
|
|
12
|
+
#
|
|
13
|
+
# @example Unset a config key
|
|
14
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Unset.new(lib)
|
|
15
|
+
# cmd.call('user.name')
|
|
16
|
+
#
|
|
17
|
+
# @example Unset a global config key
|
|
18
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Unset.new(lib)
|
|
19
|
+
# cmd.call('user.name', global: true)
|
|
20
|
+
#
|
|
21
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-config/2.53.0
|
|
22
|
+
#
|
|
23
|
+
# @see Git::Commands::ConfigOptionSyntax
|
|
24
|
+
#
|
|
25
|
+
# @see https://git-scm.com/docs/git-config git-config documentation
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
class Unset < Git::Commands::Base
|
|
29
|
+
arguments do
|
|
30
|
+
literal 'config'
|
|
31
|
+
literal '--unset'
|
|
32
|
+
|
|
33
|
+
# File-scope options
|
|
34
|
+
flag_option :global
|
|
35
|
+
flag_option :system
|
|
36
|
+
flag_option :local
|
|
37
|
+
flag_option :worktree
|
|
38
|
+
value_option %i[file f]
|
|
39
|
+
value_option :blob
|
|
40
|
+
|
|
41
|
+
# Value matching
|
|
42
|
+
flag_option :fixed_value
|
|
43
|
+
|
|
44
|
+
# Operands
|
|
45
|
+
end_of_options
|
|
46
|
+
operand :name, required: true
|
|
47
|
+
operand :value_regex
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# git config --unset exits 5 when trying to unset a non-existent or multi-valued key
|
|
51
|
+
allow_exit_status 0..5
|
|
52
|
+
|
|
53
|
+
# @overload call(name, value_regex = nil, **options)
|
|
54
|
+
#
|
|
55
|
+
# Execute the `git config --unset` command
|
|
56
|
+
#
|
|
57
|
+
# @param name [String] the config key name to unset
|
|
58
|
+
#
|
|
59
|
+
# @param value_regex [String, nil] (nil) optional regex to match the value to remove
|
|
60
|
+
#
|
|
61
|
+
# @param options [Hash] command options
|
|
62
|
+
#
|
|
63
|
+
# @option options [Boolean, nil] :global (nil) remove from global config (`~/.gitconfig`)
|
|
64
|
+
#
|
|
65
|
+
# @option options [Boolean, nil] :system (nil) remove from system config
|
|
66
|
+
#
|
|
67
|
+
# @option options [Boolean, nil] :local (nil) remove from repository config (`.git/config`)
|
|
68
|
+
#
|
|
69
|
+
# @option options [Boolean, nil] :worktree (nil) remove from worktree config
|
|
70
|
+
#
|
|
71
|
+
# @option options [String] :file (nil) remove from the specified file
|
|
72
|
+
#
|
|
73
|
+
# Alias: :f
|
|
74
|
+
#
|
|
75
|
+
# @option options [String] :blob (nil) read from the specified blob
|
|
76
|
+
#
|
|
77
|
+
# @option options [Boolean, nil] :fixed_value (nil) treat the value regex as an exact string
|
|
78
|
+
#
|
|
79
|
+
# @return [Git::CommandLine::Result] the result of calling `git config --unset`
|
|
80
|
+
#
|
|
81
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
82
|
+
#
|
|
83
|
+
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 5)
|
|
84
|
+
#
|
|
85
|
+
# @api public
|
|
86
|
+
def call(*, **)
|
|
87
|
+
super
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module ConfigOptionSyntax
|
|
8
|
+
# Remove all matching config entries
|
|
9
|
+
#
|
|
10
|
+
# Wraps `git config --unset-all` to remove all entries matching the
|
|
11
|
+
# given key name and optional value regex.
|
|
12
|
+
#
|
|
13
|
+
# @example Unset all values for a key
|
|
14
|
+
# cmd = Git::Commands::ConfigOptionSyntax::UnsetAll.new(lib)
|
|
15
|
+
# cmd.call('remote.origin.fetch')
|
|
16
|
+
#
|
|
17
|
+
# @example Unset all values matching a pattern
|
|
18
|
+
# cmd = Git::Commands::ConfigOptionSyntax::UnsetAll.new(lib)
|
|
19
|
+
# cmd.call('core.gitproxy', 'for kernel.org$')
|
|
20
|
+
#
|
|
21
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-config/2.53.0
|
|
22
|
+
#
|
|
23
|
+
# @see Git::Commands::ConfigOptionSyntax
|
|
24
|
+
#
|
|
25
|
+
# @see https://git-scm.com/docs/git-config git-config documentation
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
class UnsetAll < Git::Commands::Base
|
|
29
|
+
arguments do
|
|
30
|
+
literal 'config'
|
|
31
|
+
literal '--unset-all'
|
|
32
|
+
|
|
33
|
+
# File-scope options
|
|
34
|
+
flag_option :global
|
|
35
|
+
flag_option :system
|
|
36
|
+
flag_option :local
|
|
37
|
+
flag_option :worktree
|
|
38
|
+
value_option %i[file f]
|
|
39
|
+
value_option :blob
|
|
40
|
+
|
|
41
|
+
# Value matching
|
|
42
|
+
flag_option :fixed_value
|
|
43
|
+
|
|
44
|
+
# Operands
|
|
45
|
+
end_of_options
|
|
46
|
+
operand :name, required: true
|
|
47
|
+
operand :value_regex
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# git config --unset-all exits 5 when trying to unset a non-existent key
|
|
51
|
+
allow_exit_status 0..5
|
|
52
|
+
|
|
53
|
+
# @!method call(*, **options)
|
|
54
|
+
#
|
|
55
|
+
# @param options [Hash] command options
|
|
56
|
+
#
|
|
57
|
+
# @option options [Boolean, nil] :global (nil) command option key; see
|
|
58
|
+
# overload docs for the full option list
|
|
59
|
+
#
|
|
60
|
+
# @overload call(name, value_regex = nil, **options)
|
|
61
|
+
#
|
|
62
|
+
# Execute the `git config --unset-all` command
|
|
63
|
+
#
|
|
64
|
+
# @param name [String] the config key name to unset
|
|
65
|
+
#
|
|
66
|
+
# @param value_regex [String, nil] (nil) optional regex to match values to remove
|
|
67
|
+
#
|
|
68
|
+
# @param options [Hash] command options
|
|
69
|
+
#
|
|
70
|
+
# @option options [Boolean, nil] :global (nil) remove from global config (`~/.gitconfig`)
|
|
71
|
+
#
|
|
72
|
+
# @option options [Boolean, nil] :system (nil) remove from system config
|
|
73
|
+
#
|
|
74
|
+
# @option options [Boolean, nil] :local (nil) remove from repository config (`.git/config`)
|
|
75
|
+
#
|
|
76
|
+
# @option options [Boolean, nil] :worktree (nil) remove from worktree config
|
|
77
|
+
#
|
|
78
|
+
# @option options [String] :file (nil) remove from the specified file
|
|
79
|
+
#
|
|
80
|
+
# Alias: :f
|
|
81
|
+
#
|
|
82
|
+
# @option options [String] :blob (nil) read from the specified blob
|
|
83
|
+
#
|
|
84
|
+
# @option options [Boolean, nil] :fixed_value (nil) treat the value regex as an exact string
|
|
85
|
+
#
|
|
86
|
+
# @return [Git::CommandLine::Result] the result of calling `git config --unset-all`
|
|
87
|
+
#
|
|
88
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
89
|
+
#
|
|
90
|
+
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 5)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'config_option_syntax/add'
|
|
4
|
+
require_relative 'config_option_syntax/get'
|
|
5
|
+
require_relative 'config_option_syntax/get_all'
|
|
6
|
+
require_relative 'config_option_syntax/get_color'
|
|
7
|
+
require_relative 'config_option_syntax/get_color_bool'
|
|
8
|
+
require_relative 'config_option_syntax/get_regexp'
|
|
9
|
+
require_relative 'config_option_syntax/get_urlmatch'
|
|
10
|
+
require_relative 'config_option_syntax/list'
|
|
11
|
+
require_relative 'config_option_syntax/remove_section'
|
|
12
|
+
require_relative 'config_option_syntax/rename_section'
|
|
13
|
+
require_relative 'config_option_syntax/replace_all'
|
|
14
|
+
require_relative 'config_option_syntax/set'
|
|
15
|
+
require_relative 'config_option_syntax/unset'
|
|
16
|
+
require_relative 'config_option_syntax/unset_all'
|
|
17
|
+
|
|
18
|
+
module Git
|
|
19
|
+
module Commands
|
|
20
|
+
# Implements the `git config` command using the option-based interface
|
|
21
|
+
#
|
|
22
|
+
# This module contains command classes for the pre-2.46.0 option-based
|
|
23
|
+
# `git config` interface (`--get`, `--list`, `--add`, etc.):
|
|
24
|
+
#
|
|
25
|
+
# **Read operations:**
|
|
26
|
+
# - {ConfigOptionSyntax::Get} — retrieve a single value (`--get`)
|
|
27
|
+
# - {ConfigOptionSyntax::GetAll} — retrieve all values for a multi-valued key (`--get-all`)
|
|
28
|
+
# - {ConfigOptionSyntax::GetRegexp} — retrieve values matching a name regex (`--get-regexp`)
|
|
29
|
+
# - {ConfigOptionSyntax::GetUrlmatch} — retrieve URL-matched values (`--get-urlmatch`)
|
|
30
|
+
# - {ConfigOptionSyntax::GetColor} — retrieve an ANSI color string (`--get-color`)
|
|
31
|
+
# - {ConfigOptionSyntax::GetColorBool} — query whether color output is enabled (`--get-colorbool`)
|
|
32
|
+
# - {ConfigOptionSyntax::List} — list all config entries (`--list`)
|
|
33
|
+
#
|
|
34
|
+
# **Write operations:**
|
|
35
|
+
# - {ConfigOptionSyntax::Set} — set a config value (implicit set mode)
|
|
36
|
+
# - {ConfigOptionSyntax::Add} — append a value to a multi-valued key (`--add`)
|
|
37
|
+
# - {ConfigOptionSyntax::ReplaceAll} — replace all matching values (`--replace-all`)
|
|
38
|
+
#
|
|
39
|
+
# **Delete operations:**
|
|
40
|
+
# - {ConfigOptionSyntax::Unset} — remove a single value (`--unset`)
|
|
41
|
+
# - {ConfigOptionSyntax::UnsetAll} — remove all matching values (`--unset-all`)
|
|
42
|
+
#
|
|
43
|
+
# **Section operations:**
|
|
44
|
+
# - {ConfigOptionSyntax::RenameSection} — rename a config section (`--rename-section`)
|
|
45
|
+
# - {ConfigOptionSyntax::RemoveSection} — remove a config section (`--remove-section`)
|
|
46
|
+
#
|
|
47
|
+
# @see https://git-scm.com/docs/git-config/2.28.0 git-config documentation (v2.28.0)
|
|
48
|
+
#
|
|
49
|
+
# @see Git::Commands
|
|
50
|
+
#
|
|
51
|
+
# @api private
|
|
52
|
+
#
|
|
53
|
+
module ConfigOptionSyntax
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git describe` command
|
|
8
|
+
#
|
|
9
|
+
# Gives a human-readable name to a commit based on the most recent
|
|
10
|
+
# reachable tag. When the tag points directly at the commit, only the
|
|
11
|
+
# tag name is shown. Otherwise, the tag name is suffixed with the number
|
|
12
|
+
# of additional commits and the abbreviated commit SHA.
|
|
13
|
+
#
|
|
14
|
+
# @example Typical usage
|
|
15
|
+
# describe = Git::Commands::Describe.new(execution_context)
|
|
16
|
+
# describe.call
|
|
17
|
+
# describe.call('abc123')
|
|
18
|
+
# describe.call(tags: true)
|
|
19
|
+
# describe.call(dirty: true)
|
|
20
|
+
# describe.call(dirty: '-dirty')
|
|
21
|
+
#
|
|
22
|
+
# @note `arguments` block audited against
|
|
23
|
+
# https://git-scm.com/docs/git-describe/2.53.0
|
|
24
|
+
#
|
|
25
|
+
# @see https://git-scm.com/docs/git-describe git-describe
|
|
26
|
+
#
|
|
27
|
+
# @see Git::Commands
|
|
28
|
+
#
|
|
29
|
+
# @api private
|
|
30
|
+
#
|
|
31
|
+
class Describe < Git::Commands::Base
|
|
32
|
+
arguments do
|
|
33
|
+
literal 'describe'
|
|
34
|
+
|
|
35
|
+
# Ref selection
|
|
36
|
+
flag_option :all
|
|
37
|
+
flag_option :tags
|
|
38
|
+
flag_option :contains
|
|
39
|
+
|
|
40
|
+
# Abbreviation
|
|
41
|
+
flag_or_value_option :abbrev, inline: true
|
|
42
|
+
|
|
43
|
+
# Working tree state
|
|
44
|
+
flag_or_value_option :dirty, inline: true
|
|
45
|
+
flag_or_value_option :broken, inline: true
|
|
46
|
+
|
|
47
|
+
# Match candidates
|
|
48
|
+
value_option :candidates, inline: true
|
|
49
|
+
flag_option :exact_match
|
|
50
|
+
|
|
51
|
+
# Output control
|
|
52
|
+
flag_option :debug
|
|
53
|
+
flag_option :long
|
|
54
|
+
|
|
55
|
+
# Pattern filtering
|
|
56
|
+
value_option :match, repeatable: true
|
|
57
|
+
value_option :exclude, repeatable: true
|
|
58
|
+
|
|
59
|
+
# Fallback and history
|
|
60
|
+
flag_option :always
|
|
61
|
+
flag_option :first_parent
|
|
62
|
+
|
|
63
|
+
end_of_options
|
|
64
|
+
operand :commit_ish, repeatable: true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @overload call(*commit_ish, **options)
|
|
68
|
+
#
|
|
69
|
+
# Execute the `git describe` command
|
|
70
|
+
#
|
|
71
|
+
# @param commit_ish [Array<String>] zero or more commit-ish objects
|
|
72
|
+
# to describe
|
|
73
|
+
#
|
|
74
|
+
# When none are given, describes HEAD.
|
|
75
|
+
#
|
|
76
|
+
# @param options [Hash] command options
|
|
77
|
+
#
|
|
78
|
+
# @option options [Boolean, nil] :all (nil) use any ref found in the
|
|
79
|
+
# `refs/` namespace, not just tags
|
|
80
|
+
#
|
|
81
|
+
# @option options [Boolean, nil] :tags (nil) use any tag found in the
|
|
82
|
+
# `refs/tags` namespace, instead of only annotated tags
|
|
83
|
+
#
|
|
84
|
+
# @option options [Boolean, nil] :contains (nil) find the tag that
|
|
85
|
+
# comes after the commit and thus contains it, rather than the
|
|
86
|
+
# most recent tag reachable from it
|
|
87
|
+
#
|
|
88
|
+
# @option options [Boolean, String, nil] :abbrev (nil) use this many
|
|
89
|
+
# digits for the abbreviated commit object name
|
|
90
|
+
#
|
|
91
|
+
# When `true`, emits bare `--abbrev` (which uses git's default
|
|
92
|
+
# length). Pass a string to emit `--abbrev=<n>`.
|
|
93
|
+
#
|
|
94
|
+
# @option options [Boolean, String, nil] :dirty (nil) describe the
|
|
95
|
+
# working tree
|
|
96
|
+
#
|
|
97
|
+
# When `true`, appends `-dirty`; when a String, appends that
|
|
98
|
+
# string as the dirty mark. Maps to `--dirty[=<mark>]`.
|
|
99
|
+
#
|
|
100
|
+
# @option options [Boolean, String, nil] :broken (nil) describe the
|
|
101
|
+
# working tree, treating broken links as dirty
|
|
102
|
+
#
|
|
103
|
+
# When `true`, appends `-broken`; when a String, appends that
|
|
104
|
+
# string as the broken mark. Maps to `--broken[=<mark>]`.
|
|
105
|
+
#
|
|
106
|
+
# @option options [Integer, String] :candidates (nil) consider up
|
|
107
|
+
# to this many candidates
|
|
108
|
+
#
|
|
109
|
+
# Increasing above the default of 10 will take a slightly
|
|
110
|
+
# longer time but may produce a more accurate result. Maps to
|
|
111
|
+
# `--candidates=<n>`.
|
|
112
|
+
#
|
|
113
|
+
# @option options [Boolean, nil] :exact_match (nil) only output exact
|
|
114
|
+
# matches (a tag directly references the supplied commit object)
|
|
115
|
+
#
|
|
116
|
+
# @option options [Boolean, nil] :debug (nil) verbosely display
|
|
117
|
+
# information about the searching strategy being employed
|
|
118
|
+
#
|
|
119
|
+
# @option options [Boolean, nil] :long (nil) always output the long
|
|
120
|
+
# format (the tag, the number of commits, and the abbreviated
|
|
121
|
+
# object name) even when it matches a tag exactly
|
|
122
|
+
#
|
|
123
|
+
# @option options [String, Array<String>] :match (nil) only
|
|
124
|
+
# consider tags matching the given `glob(7)` pattern
|
|
125
|
+
#
|
|
126
|
+
# Pass an array to match against multiple patterns. Maps to
|
|
127
|
+
# `--match <pattern>`.
|
|
128
|
+
#
|
|
129
|
+
# @option options [String, Array<String>] :exclude (nil) do not
|
|
130
|
+
# consider tags matching the given `glob(7)` pattern
|
|
131
|
+
#
|
|
132
|
+
# Pass an array to exclude multiple patterns. Maps to
|
|
133
|
+
# `--exclude <pattern>`.
|
|
134
|
+
#
|
|
135
|
+
# @option options [Boolean, nil] :always (nil) show uniquely
|
|
136
|
+
# abbreviated commit object as fallback when the commit cannot
|
|
137
|
+
# be described
|
|
138
|
+
#
|
|
139
|
+
# @option options [Boolean, nil] :first_parent (nil) follow only the
|
|
140
|
+
# first parent of a merge commit
|
|
141
|
+
#
|
|
142
|
+
# @return [Git::CommandLine::Result] the result of calling
|
|
143
|
+
# `git describe`
|
|
144
|
+
#
|
|
145
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
146
|
+
#
|
|
147
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit
|
|
148
|
+
# status
|
|
149
|
+
#
|
|
150
|
+
# @api public
|
|
151
|
+
def call(*, **)
|
|
152
|
+
super
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|