git 4.3.2 → 5.0.0.beta.1
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/.github/copilot-instructions.md +67 -2705
- data/.github/pull_request_template.md +3 -1
- data/.github/skills/breaking-change-analysis/SKILL.md +102 -0
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +264 -0
- data/.github/skills/command-implementation/REFERENCE.md +993 -0
- data/.github/skills/command-implementation/SKILL.md +229 -0
- data/.github/skills/command-test-conventions/SKILL.md +660 -0
- data/.github/skills/command-yard-documentation/SKILL.md +426 -0
- data/.github/skills/dependency-management/SKILL.md +72 -0
- data/.github/skills/development-workflow/SKILL.md +506 -0
- data/.github/skills/extract-command-from-lib/SKILL.md +487 -0
- data/.github/skills/extract-facade-from-base-lib/SKILL.md +586 -0
- data/.github/skills/facade-implementation/REFERENCE.md +840 -0
- data/.github/skills/facade-implementation/SKILL.md +260 -0
- data/.github/skills/facade-test-conventions/SKILL.md +380 -0
- data/.github/skills/facade-yard-documentation/SKILL.md +429 -0
- data/.github/skills/make-skill-template/SKILL.md +176 -0
- data/.github/skills/pr-readiness-review/SKILL.md +185 -0
- data/.github/skills/project-context/SKILL.md +313 -0
- data/.github/skills/pull-request-review/SKILL.md +168 -0
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +131 -0
- data/.github/skills/release-management/SKILL.md +125 -0
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +788 -0
- data/.github/skills/review-arguments-dsl/SKILL.md +214 -0
- data/.github/skills/review-backward-compatibility/SKILL.md +275 -0
- data/.github/skills/review-cross-command-consistency/SKILL.md +139 -0
- data/.github/skills/reviewing-skills/SKILL.md +189 -0
- data/.github/skills/rspec-unit-testing-standards/SKILL.md +639 -0
- data/.github/skills/tdd-refactor-step/SKILL.md +236 -0
- data/.github/skills/test-debugging/SKILL.md +160 -0
- data/.github/skills/yard-documentation/SKILL.md +793 -0
- data/.github/workflows/continuous_integration.yml +3 -2
- data/.github/workflows/enforce_conventional_commits.yml +1 -1
- data/.github/workflows/experimental_continuous_integration.yml +2 -2
- data/.github/workflows/release.yml +3 -4
- data/.gitignore +8 -0
- data/.husky/pre-commit +13 -0
- data/.release-please-manifest.json +1 -1
- data/.rspec +3 -0
- data/.rubocop.yml +7 -3
- data/.rubocop_todo.yml +23 -5
- data/.yardopts +1 -0
- data/CHANGELOG.md +0 -40
- data/CONTRIBUTING.md +694 -53
- data/README.md +17 -5
- data/Rakefile +61 -9
- data/commitlint.test +4 -0
- data/git.gemspec +14 -8
- data/lib/git/args_builder.rb +0 -8
- data/lib/git/base.rb +486 -410
- data/lib/git/branch.rb +380 -43
- data/lib/git/branch_delete_failure.rb +31 -0
- data/lib/git/branch_delete_result.rb +63 -0
- data/lib/git/branch_info.rb +178 -0
- data/lib/git/branches.rb +130 -24
- data/lib/git/command_line/base.rb +245 -0
- data/lib/git/command_line/capturing.rb +249 -0
- data/lib/git/command_line/result.rb +96 -0
- data/lib/git/command_line/streaming.rb +194 -0
- data/lib/git/command_line.rb +43 -322
- data/lib/git/command_line_result.rb +4 -88
- data/lib/git/commands/add.rb +131 -0
- data/lib/git/commands/am/abort.rb +43 -0
- data/lib/git/commands/am/apply.rb +252 -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 +47 -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 +237 -0
- data/lib/git/commands/archive/list_formats.rb +46 -0
- data/lib/git/commands/archive.rb +140 -0
- data/lib/git/commands/arguments.rb +3510 -0
- data/lib/git/commands/base.rb +403 -0
- data/lib/git/commands/branch/copy.rb +94 -0
- data/lib/git/commands/branch/create.rb +173 -0
- data/lib/git/commands/branch/delete.rb +80 -0
- data/lib/git/commands/branch/list.rb +162 -0
- data/lib/git/commands/branch/move.rb +94 -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 +57 -0
- data/lib/git/commands/branch.rb +34 -0
- data/lib/git/commands/cat_file/batch.rb +364 -0
- data/lib/git/commands/cat_file/filtered.rb +105 -0
- data/lib/git/commands/cat_file/raw.rb +210 -0
- data/lib/git/commands/cat_file.rb +49 -0
- data/lib/git/commands/checkout/branch.rb +151 -0
- data/lib/git/commands/checkout/files.rb +115 -0
- data/lib/git/commands/checkout.rb +38 -0
- data/lib/git/commands/checkout_index.rb +105 -0
- data/lib/git/commands/clean.rb +100 -0
- data/lib/git/commands/clone.rb +240 -0
- data/lib/git/commands/commit.rb +272 -0
- data/lib/git/commands/commit_tree.rb +100 -0
- data/lib/git/commands/config_option_syntax/add.rb +83 -0
- data/lib/git/commands/config_option_syntax/get.rb +117 -0
- data/lib/git/commands/config_option_syntax/get_all.rb +115 -0
- data/lib/git/commands/config_option_syntax/get_color.rb +91 -0
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +93 -0
- data/lib/git/commands/config_option_syntax/get_regexp.rb +115 -0
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +102 -0
- data/lib/git/commands/config_option_syntax/list.rb +107 -0
- data/lib/git/commands/config_option_syntax/remove_section.rb +74 -0
- data/lib/git/commands/config_option_syntax/rename_section.rb +78 -0
- data/lib/git/commands/config_option_syntax/replace_all.rb +104 -0
- data/lib/git/commands/config_option_syntax/set.rb +114 -0
- data/lib/git/commands/config_option_syntax/unset.rb +89 -0
- data/lib/git/commands/config_option_syntax/unset_all.rb +89 -0
- data/lib/git/commands/config_option_syntax.rb +56 -0
- data/lib/git/commands/describe.rb +155 -0
- data/lib/git/commands/diff.rb +656 -0
- data/lib/git/commands/diff_files.rb +518 -0
- data/lib/git/commands/diff_index.rb +496 -0
- data/lib/git/commands/fetch.rb +352 -0
- data/lib/git/commands/fsck.rb +136 -0
- data/lib/git/commands/gc.rb +132 -0
- data/lib/git/commands/grep.rb +338 -0
- data/lib/git/commands/init.rb +99 -0
- data/lib/git/commands/log.rb +632 -0
- data/lib/git/commands/ls_files.rb +191 -0
- data/lib/git/commands/ls_remote.rb +155 -0
- data/lib/git/commands/ls_tree.rb +131 -0
- data/lib/git/commands/maintenance/register.rb +75 -0
- data/lib/git/commands/maintenance/run.rb +104 -0
- data/lib/git/commands/maintenance/start.rb +66 -0
- data/lib/git/commands/maintenance/stop.rb +55 -0
- data/lib/git/commands/maintenance/unregister.rb +79 -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 +245 -0
- data/lib/git/commands/merge.rb +28 -0
- data/lib/git/commands/merge_base.rb +86 -0
- data/lib/git/commands/mv.rb +77 -0
- data/lib/git/commands/name_rev.rb +114 -0
- data/lib/git/commands/pull.rb +377 -0
- data/lib/git/commands/push.rb +246 -0
- data/lib/git/commands/read_tree.rb +149 -0
- data/lib/git/commands/remote/add.rb +91 -0
- data/lib/git/commands/remote/get_url.rb +66 -0
- data/lib/git/commands/remote/list.rb +54 -0
- data/lib/git/commands/remote/prune.rb +61 -0
- data/lib/git/commands/remote/remove.rb +52 -0
- data/lib/git/commands/remote/rename.rb +69 -0
- data/lib/git/commands/remote/set_branches.rb +63 -0
- data/lib/git/commands/remote/set_head.rb +82 -0
- data/lib/git/commands/remote/set_url.rb +71 -0
- data/lib/git/commands/remote/set_url_add.rb +61 -0
- data/lib/git/commands/remote/set_url_delete.rb +64 -0
- data/lib/git/commands/remote/show.rb +71 -0
- data/lib/git/commands/remote/update.rb +72 -0
- data/lib/git/commands/remote.rb +42 -0
- data/lib/git/commands/repack.rb +277 -0
- data/lib/git/commands/reset.rb +147 -0
- data/lib/git/commands/rev_parse.rb +297 -0
- data/lib/git/commands/revert/abort.rb +45 -0
- data/lib/git/commands/revert/continue.rb +57 -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 +153 -0
- data/lib/git/commands/revert.rb +29 -0
- data/lib/git/commands/rm.rb +114 -0
- data/lib/git/commands/show.rb +632 -0
- data/lib/git/commands/show_ref/exclude_existing.rb +120 -0
- data/lib/git/commands/show_ref/exists.rb +78 -0
- data/lib/git/commands/show_ref/list.rb +145 -0
- data/lib/git/commands/show_ref/verify.rb +120 -0
- data/lib/git/commands/show_ref.rb +42 -0
- data/lib/git/commands/stash/apply.rb +75 -0
- data/lib/git/commands/stash/branch.rb +65 -0
- data/lib/git/commands/stash/clear.rb +41 -0
- data/lib/git/commands/stash/create.rb +58 -0
- data/lib/git/commands/stash/drop.rb +67 -0
- data/lib/git/commands/stash/list.rb +39 -0
- data/lib/git/commands/stash/pop.rb +78 -0
- data/lib/git/commands/stash/push.rb +103 -0
- data/lib/git/commands/stash/show.rb +149 -0
- data/lib/git/commands/stash/store.rb +63 -0
- data/lib/git/commands/stash.rb +38 -0
- data/lib/git/commands/status.rb +169 -0
- data/lib/git/commands/symbolic_ref/delete.rb +68 -0
- data/lib/git/commands/symbolic_ref/read.rb +95 -0
- data/lib/git/commands/symbolic_ref/update.rb +76 -0
- data/lib/git/commands/symbolic_ref.rb +38 -0
- data/lib/git/commands/tag/create.rb +139 -0
- data/lib/git/commands/tag/delete.rb +55 -0
- data/lib/git/commands/tag/list.rb +143 -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 +140 -0
- data/lib/git/commands/update_ref/delete.rb +92 -0
- data/lib/git/commands/update_ref/update.rb +106 -0
- data/lib/git/commands/update_ref.rb +42 -0
- data/lib/git/commands/version.rb +52 -0
- data/lib/git/commands/worktree/add.rb +140 -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 +89 -0
- data/lib/git/detached_head_info.rb +54 -0
- data/lib/git/diff.rb +297 -7
- data/lib/git/diff_file_numstat_info.rb +29 -0
- data/lib/git/diff_file_patch_info.rb +134 -0
- data/lib/git/diff_file_raw_info.rb +127 -0
- data/lib/git/diff_info.rb +169 -0
- data/lib/git/diff_path_status.rb +78 -19
- data/lib/git/diff_result.rb +32 -0
- data/lib/git/diff_stats.rb +59 -14
- data/lib/git/dirstat_info.rb +86 -0
- data/lib/git/errors.rb +65 -2
- data/lib/git/execution_context/global.rb +56 -0
- data/lib/git/execution_context/repository.rb +147 -0
- data/lib/git/execution_context.rb +482 -0
- data/lib/git/file_ref.rb +74 -0
- data/lib/git/fsck_object.rb +9 -9
- data/lib/git/fsck_result.rb +1 -1
- data/lib/git/lib.rb +1606 -1028
- data/lib/git/log.rb +15 -2
- data/lib/git/object.rb +92 -22
- data/lib/git/parsers/branch.rb +224 -0
- data/lib/git/parsers/cat_file.rb +111 -0
- data/lib/git/parsers/diff.rb +585 -0
- data/lib/git/parsers/fsck.rb +133 -0
- data/lib/git/parsers/grep.rb +42 -0
- data/lib/git/parsers/ls_tree.rb +58 -0
- data/lib/git/parsers/stash.rb +208 -0
- data/lib/git/parsers/tag.rb +257 -0
- data/lib/git/remote.rb +133 -9
- data/lib/git/repository/branching.rb +572 -0
- data/lib/git/repository/committing.rb +191 -0
- data/lib/git/repository/configuring.rb +156 -0
- data/lib/git/repository/diffing.rb +775 -0
- data/lib/git/repository/inspecting.rb +153 -0
- data/lib/git/repository/logging.rb +247 -0
- data/lib/git/repository/merging.rb +295 -0
- data/lib/git/repository/object_operations.rb +1101 -0
- data/lib/git/repository/path_resolver.rb +207 -0
- data/lib/git/repository/remote_operations.rb +753 -0
- data/lib/git/repository/shared_private.rb +51 -0
- data/lib/git/repository/staging.rb +390 -0
- data/lib/git/repository/stashing.rb +107 -0
- data/lib/git/repository/status_operations.rb +180 -0
- data/lib/git/repository/worktree_operations.rb +159 -0
- data/lib/git/repository.rb +264 -1
- data/lib/git/stash.rb +85 -4
- data/lib/git/stash_info.rb +104 -0
- data/lib/git/stashes.rb +130 -13
- data/lib/git/status.rb +224 -18
- data/lib/git/tag_delete_failure.rb +31 -0
- data/lib/git/tag_delete_result.rb +63 -0
- data/lib/git/tag_info.rb +105 -0
- data/lib/git/version.rb +109 -2
- data/lib/git/version_constraint.rb +81 -0
- data/lib/git/worktree.rb +120 -5
- data/lib/git/worktrees.rb +107 -7
- data/lib/git.rb +114 -18
- data/redesign/1_architecture_existing.md +54 -18
- data/redesign/2_architecture_redesign.md +365 -46
- data/redesign/3_architecture_implementation.md +1451 -54
- data/tasks/gem_tasks.rake +4 -0
- data/tasks/npm_tasks.rake +7 -0
- data/tasks/rspec.rake +48 -0
- data/tasks/test.rake +13 -1
- data/tasks/yard.rake +34 -7
- metadata +349 -20
- data/lib/git/index.rb +0 -6
- data/lib/git/path.rb +0 -38
- data/lib/git/working_directory.rb +0 -6
- /data/{release-please-config.json → .release-please-config.json} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git clone` command
|
|
8
|
+
#
|
|
9
|
+
# Clones a repository into a newly created directory.
|
|
10
|
+
#
|
|
11
|
+
# @example Typical usage
|
|
12
|
+
# clone = Git::Commands::Clone.new(execution_context)
|
|
13
|
+
# clone.call('https://github.com/user/repo.git')
|
|
14
|
+
# clone.call('https://github.com/user/repo.git', 'local-dir')
|
|
15
|
+
# clone.call('https://github.com/user/repo.git', 'local-dir', bare: true)
|
|
16
|
+
# clone.call('https://github.com/user/repo.git', 'local-dir', depth: 1)
|
|
17
|
+
#
|
|
18
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-clone/2.53.0
|
|
19
|
+
#
|
|
20
|
+
# @see https://git-scm.com/docs/git-clone git-clone
|
|
21
|
+
#
|
|
22
|
+
# @see Git::Commands
|
|
23
|
+
#
|
|
24
|
+
# @api private
|
|
25
|
+
#
|
|
26
|
+
class Clone < Git::Commands::Base
|
|
27
|
+
arguments do
|
|
28
|
+
literal 'clone'
|
|
29
|
+
value_option :template, inline: true
|
|
30
|
+
flag_option %i[local l], negatable: true
|
|
31
|
+
flag_option %i[shared s]
|
|
32
|
+
flag_option :no_hardlinks
|
|
33
|
+
flag_option %i[quiet q]
|
|
34
|
+
flag_option %i[verbose v]
|
|
35
|
+
flag_option :progress
|
|
36
|
+
flag_option %i[no_checkout n]
|
|
37
|
+
flag_option :bare
|
|
38
|
+
flag_option :mirror
|
|
39
|
+
value_option %i[origin o]
|
|
40
|
+
value_option %i[branch b]
|
|
41
|
+
value_option :revision, inline: true
|
|
42
|
+
value_option %i[upload_pack u]
|
|
43
|
+
value_option :reference, repeatable: true
|
|
44
|
+
value_option :reference_if_able, repeatable: true
|
|
45
|
+
flag_option :dissociate
|
|
46
|
+
value_option :separate_git_dir, inline: true
|
|
47
|
+
value_option :server_option, inline: true, repeatable: true
|
|
48
|
+
value_option :depth
|
|
49
|
+
value_option :shallow_since, inline: true
|
|
50
|
+
value_option :shallow_exclude, inline: true, repeatable: true
|
|
51
|
+
flag_option :single_branch, negatable: true
|
|
52
|
+
flag_option :tags, negatable: true
|
|
53
|
+
flag_or_value_option :recurse_submodules, inline: true, repeatable: true
|
|
54
|
+
flag_option :shallow_submodules, negatable: true
|
|
55
|
+
flag_option :remote_submodules, negatable: true
|
|
56
|
+
value_option %i[jobs j]
|
|
57
|
+
flag_option :sparse
|
|
58
|
+
flag_option :reject_shallow, negatable: true
|
|
59
|
+
value_option :filter, inline: true
|
|
60
|
+
flag_option :also_filter_submodules
|
|
61
|
+
value_option %i[config c], repeatable: true
|
|
62
|
+
value_option :bundle_uri, inline: true
|
|
63
|
+
value_option :ref_format, inline: true
|
|
64
|
+
end_of_options
|
|
65
|
+
operand :repository, required: true
|
|
66
|
+
operand :directory
|
|
67
|
+
execution_option :timeout
|
|
68
|
+
execution_option :chdir
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @!method call(*, **)
|
|
72
|
+
#
|
|
73
|
+
# @overload call(repository, directory = nil, **options)
|
|
74
|
+
#
|
|
75
|
+
# Execute the `git clone` command
|
|
76
|
+
#
|
|
77
|
+
# @param repository [String] the URL or path of the repository to clone
|
|
78
|
+
#
|
|
79
|
+
# @param directory [String, nil] the directory to clone into; git derives the
|
|
80
|
+
# name from the repository URL when omitted
|
|
81
|
+
#
|
|
82
|
+
# @param options [Hash] command options
|
|
83
|
+
#
|
|
84
|
+
# @option options [String] :template (nil) directory from which templates
|
|
85
|
+
# will be used
|
|
86
|
+
#
|
|
87
|
+
# @option options [Boolean, nil] :local (nil) bypass the normal Git-aware transport
|
|
88
|
+
# for local clones (`--local`)
|
|
89
|
+
#
|
|
90
|
+
# Alias: `:l`
|
|
91
|
+
#
|
|
92
|
+
# @option options [Boolean, nil] :no_local (nil) disable the local optimization
|
|
93
|
+
# and use the normal transport (`--no-local`)
|
|
94
|
+
#
|
|
95
|
+
# @option options [Boolean, nil] :shared (nil) set up a shared clone using
|
|
96
|
+
# alternates instead of hardlinks
|
|
97
|
+
#
|
|
98
|
+
# Alias: `:s`
|
|
99
|
+
#
|
|
100
|
+
# @option options [Boolean, nil] :no_hardlinks (nil) force file-copy instead of
|
|
101
|
+
# hardlinks when cloning from a local filesystem
|
|
102
|
+
#
|
|
103
|
+
# @option options [Boolean, nil] :quiet (nil) suppress progress output to stderr
|
|
104
|
+
#
|
|
105
|
+
# Alias: `:q`
|
|
106
|
+
#
|
|
107
|
+
# @option options [Boolean, nil] :verbose (nil) run verbosely
|
|
108
|
+
#
|
|
109
|
+
# Alias: `:v`
|
|
110
|
+
#
|
|
111
|
+
# @option options [Boolean, nil] :progress (nil) force progress status even when
|
|
112
|
+
# stderr is not a terminal
|
|
113
|
+
#
|
|
114
|
+
# @option options [Boolean, nil] :no_checkout (nil) skip checking out HEAD after
|
|
115
|
+
# the clone
|
|
116
|
+
#
|
|
117
|
+
# Alias: `:n`
|
|
118
|
+
#
|
|
119
|
+
# @option options [Boolean, nil] :bare (nil) clone as a bare repository
|
|
120
|
+
#
|
|
121
|
+
# @option options [Boolean, nil] :mirror (nil) set up a mirror clone (implies
|
|
122
|
+
# --bare)
|
|
123
|
+
#
|
|
124
|
+
# @option options [String] :origin (nil) name of the remote to use instead of
|
|
125
|
+
# "origin"
|
|
126
|
+
#
|
|
127
|
+
# Alias: `:o`
|
|
128
|
+
#
|
|
129
|
+
# @option options [String] :branch (nil) branch to check out after cloning
|
|
130
|
+
#
|
|
131
|
+
# Alias: `:b`
|
|
132
|
+
#
|
|
133
|
+
# @option options [String] :revision (nil) detach HEAD at the given revision
|
|
134
|
+
# after cloning; incompatible with :branch and :mirror
|
|
135
|
+
#
|
|
136
|
+
# @option options [String] :upload_pack (nil) path to git-upload-pack on the
|
|
137
|
+
# remote (ssh only)
|
|
138
|
+
#
|
|
139
|
+
# Alias: `:u`
|
|
140
|
+
#
|
|
141
|
+
# @option options [String, Array<String>] :reference (nil) borrow objects from
|
|
142
|
+
# one or more reference repositories
|
|
143
|
+
#
|
|
144
|
+
# @option options [String, Array<String>] :reference_if_able (nil) like
|
|
145
|
+
# :reference but skip with a warning when the reference does not exist
|
|
146
|
+
#
|
|
147
|
+
# @option options [Boolean, nil] :dissociate (nil) stop borrowing from reference
|
|
148
|
+
# repositories after the clone is complete
|
|
149
|
+
#
|
|
150
|
+
# @option options [String] :separate_git_dir (nil) place the git directory at
|
|
151
|
+
# the given path and create a gitfile symlink in the working tree
|
|
152
|
+
#
|
|
153
|
+
# @option options [String, Array<String>] :server_option (nil) protocol-v2
|
|
154
|
+
# server options
|
|
155
|
+
#
|
|
156
|
+
# @option options [Integer, String] :depth (nil) create a shallow clone with
|
|
157
|
+
# the specified number of commits
|
|
158
|
+
#
|
|
159
|
+
# @option options [String] :shallow_since (nil) create a shallow clone with
|
|
160
|
+
# history after the specified date
|
|
161
|
+
#
|
|
162
|
+
# @option options [String, Array<String>] :shallow_exclude (nil) exclude
|
|
163
|
+
# commits reachable from the specified remote branch or tag
|
|
164
|
+
#
|
|
165
|
+
# @option options [Boolean, nil] :single_branch (nil) clone only the history for
|
|
166
|
+
# one branch (`--single-branch`)
|
|
167
|
+
#
|
|
168
|
+
# @option options [Boolean, nil] :no_single_branch (nil) clone history for all
|
|
169
|
+
# branches (`--no-single-branch`)
|
|
170
|
+
#
|
|
171
|
+
# @option options [Boolean, nil] :tags (nil) include tags in the clone (`--tags`)
|
|
172
|
+
#
|
|
173
|
+
# @option options [Boolean, nil] :no_tags (nil) exclude tags from the clone
|
|
174
|
+
# (`--no-tags`)
|
|
175
|
+
#
|
|
176
|
+
# @option options [Boolean, String, Array<String>, nil] :recurse_submodules (nil)
|
|
177
|
+
# initialize submodules after cloning; pass true for all submodules or a
|
|
178
|
+
# pathspec string/array for a subset
|
|
179
|
+
#
|
|
180
|
+
# @option options [Boolean, nil] :shallow_submodules (nil) clone submodules with
|
|
181
|
+
# depth 1 (`--shallow-submodules`)
|
|
182
|
+
#
|
|
183
|
+
# @option options [Boolean, nil] :no_shallow_submodules (nil) clone submodules
|
|
184
|
+
# with full history (`--no-shallow-submodules`)
|
|
185
|
+
#
|
|
186
|
+
# @option options [Boolean, nil] :remote_submodules (nil) use submodule
|
|
187
|
+
# remote-tracking branch status (`--remote-submodules`)
|
|
188
|
+
#
|
|
189
|
+
# @option options [Boolean, nil] :no_remote_submodules (nil) use the locally
|
|
190
|
+
# recorded SHA-1 for submodules (`--no-remote-submodules`)
|
|
191
|
+
#
|
|
192
|
+
# @option options [Integer, String] :jobs (nil) number of submodules fetched
|
|
193
|
+
# concurrently
|
|
194
|
+
#
|
|
195
|
+
# Alias: `:j`
|
|
196
|
+
#
|
|
197
|
+
# @option options [Boolean, nil] :sparse (nil) enable sparse checkout with
|
|
198
|
+
# top-level files only
|
|
199
|
+
#
|
|
200
|
+
# @option options [Boolean, nil] :reject_shallow (nil) fail if source is shallow
|
|
201
|
+
# (`--reject-shallow`)
|
|
202
|
+
#
|
|
203
|
+
# @option options [Boolean, nil] :no_reject_shallow (nil) allow cloning from
|
|
204
|
+
# shallow sources (`--no-reject-shallow`)
|
|
205
|
+
#
|
|
206
|
+
# @option options [String] :filter (nil) specify a partial clone filter
|
|
207
|
+
# (e.g., 'blob:none', 'tree:0')
|
|
208
|
+
#
|
|
209
|
+
# @option options [Boolean, nil] :also_filter_submodules (nil) apply the partial
|
|
210
|
+
# clone filter to submodules; requires :filter and :recurse_submodules
|
|
211
|
+
#
|
|
212
|
+
# @option options [String, Array<String>] :config (nil) set configuration
|
|
213
|
+
# variables in the newly-created repository
|
|
214
|
+
#
|
|
215
|
+
# Alias: `:c`
|
|
216
|
+
#
|
|
217
|
+
# @option options [String] :bundle_uri (nil) fetch a bundle from the given URI
|
|
218
|
+
# before fetching from the remote
|
|
219
|
+
#
|
|
220
|
+
# @option options [String] :ref_format (nil) specify the ref storage format
|
|
221
|
+
# (e.g., 'files', 'reftable')
|
|
222
|
+
#
|
|
223
|
+
# @option options [Numeric, nil] :timeout (nil) the number of seconds to wait
|
|
224
|
+
# for the command to complete; if nil, uses the global timeout from
|
|
225
|
+
# {Git::Config}; if 0, no timeout is enforced
|
|
226
|
+
#
|
|
227
|
+
# @option options [String, nil] :chdir (nil) the working directory in which to
|
|
228
|
+
# run the git clone command
|
|
229
|
+
#
|
|
230
|
+
# @return [Git::CommandLineResult] the result of calling `git clone`
|
|
231
|
+
#
|
|
232
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
233
|
+
#
|
|
234
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
235
|
+
#
|
|
236
|
+
# @api public
|
|
237
|
+
#
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git commit` command
|
|
8
|
+
#
|
|
9
|
+
# This command records changes to the repository by creating a new commit
|
|
10
|
+
# with the staged changes.
|
|
11
|
+
#
|
|
12
|
+
# @example Typical usage
|
|
13
|
+
# commit = Git::Commands::Commit.new(execution_context)
|
|
14
|
+
# commit.call(message: 'Initial commit')
|
|
15
|
+
# commit.call(message: 'Add feature', all: true, author: 'Jane <jane@example.com>')
|
|
16
|
+
# commit.call(amend: true, no_verify: true) # emits --no-verify
|
|
17
|
+
# commit.call('src/foo.rb', message: 'Update foo')
|
|
18
|
+
#
|
|
19
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-commit/2.53.0
|
|
20
|
+
#
|
|
21
|
+
# @see https://git-scm.com/docs/git-commit git-commit
|
|
22
|
+
#
|
|
23
|
+
# @see Git::Commands
|
|
24
|
+
#
|
|
25
|
+
# @api private
|
|
26
|
+
#
|
|
27
|
+
class Commit < Git::Commands::Base
|
|
28
|
+
arguments do
|
|
29
|
+
literal 'commit'
|
|
30
|
+
|
|
31
|
+
# Stage selection
|
|
32
|
+
flag_option %i[all a]
|
|
33
|
+
|
|
34
|
+
# Message source and editing
|
|
35
|
+
flag_option %i[edit e], negatable: true
|
|
36
|
+
flag_option :amend
|
|
37
|
+
value_option %i[reuse_message C], inline: true
|
|
38
|
+
value_option :fixup, inline: true
|
|
39
|
+
value_option :squash, inline: true
|
|
40
|
+
value_option %i[message m], inline: true, allow_empty: true
|
|
41
|
+
value_option %i[file F], inline: true
|
|
42
|
+
value_option %i[template t], inline: true
|
|
43
|
+
|
|
44
|
+
# Author / date
|
|
45
|
+
flag_option :reset_author
|
|
46
|
+
value_option :author, inline: true
|
|
47
|
+
value_option :date, inline: true, type: String
|
|
48
|
+
|
|
49
|
+
# Message cleanup and trailers
|
|
50
|
+
value_option :cleanup, inline: true
|
|
51
|
+
value_option :trailer, repeatable: true
|
|
52
|
+
|
|
53
|
+
# Hooks
|
|
54
|
+
flag_option %i[verify n], negatable: true
|
|
55
|
+
|
|
56
|
+
# Behavior
|
|
57
|
+
flag_option :allow_empty
|
|
58
|
+
flag_option :allow_empty_message
|
|
59
|
+
flag_option :no_post_rewrite
|
|
60
|
+
flag_option %i[include i]
|
|
61
|
+
flag_option %i[only o]
|
|
62
|
+
|
|
63
|
+
# Output / dry-run
|
|
64
|
+
flag_option :dry_run
|
|
65
|
+
flag_option :short
|
|
66
|
+
flag_option :branch
|
|
67
|
+
flag_option :porcelain
|
|
68
|
+
flag_option :long
|
|
69
|
+
flag_option %i[null z]
|
|
70
|
+
flag_option %i[verbose v], max_times: 2
|
|
71
|
+
flag_option %i[quiet q]
|
|
72
|
+
flag_option :status, negatable: true
|
|
73
|
+
|
|
74
|
+
# Verbose diff options
|
|
75
|
+
value_option %i[unified U], inline: true, type: Integer
|
|
76
|
+
value_option :inter_hunk_context, inline: true, type: Integer
|
|
77
|
+
|
|
78
|
+
# Signoff
|
|
79
|
+
flag_option %i[signoff s], negatable: true
|
|
80
|
+
|
|
81
|
+
# GPG signing
|
|
82
|
+
flag_or_value_option %i[gpg_sign S], negatable: true, inline: true
|
|
83
|
+
|
|
84
|
+
# Untracked files
|
|
85
|
+
flag_or_value_option %i[untracked_files u], inline: true
|
|
86
|
+
|
|
87
|
+
# Pathspec from file
|
|
88
|
+
value_option :pathspec_from_file, inline: true
|
|
89
|
+
flag_option :pathspec_file_nul
|
|
90
|
+
|
|
91
|
+
# Path selection
|
|
92
|
+
end_of_options
|
|
93
|
+
operand :pathspec, repeatable: true
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @!method call(*, **)
|
|
97
|
+
#
|
|
98
|
+
# @overload call(*pathspec, **options)
|
|
99
|
+
#
|
|
100
|
+
# Execute the `git commit` command.
|
|
101
|
+
#
|
|
102
|
+
# @param pathspec [Array<String>] zero or more paths to commit
|
|
103
|
+
#
|
|
104
|
+
# When given, only changes to the listed paths are committed, ignoring
|
|
105
|
+
# staged changes for other paths.
|
|
106
|
+
#
|
|
107
|
+
# @param options [Hash] command options
|
|
108
|
+
#
|
|
109
|
+
# @option options [Boolean, nil] :all (nil) automatically stage modified and deleted
|
|
110
|
+
# files before committing
|
|
111
|
+
#
|
|
112
|
+
# Alias: `:a`
|
|
113
|
+
#
|
|
114
|
+
# @option options [Boolean, nil] :edit (nil) open an editor for the commit message (`--edit`)
|
|
115
|
+
#
|
|
116
|
+
# Alias: `:e`
|
|
117
|
+
#
|
|
118
|
+
# @option options [Boolean, nil] :no_edit (nil) suppress the editor (`--no-edit`)
|
|
119
|
+
#
|
|
120
|
+
# @option options [Boolean, nil] :amend (nil) replace the tip of the current branch
|
|
121
|
+
# with a new commit
|
|
122
|
+
#
|
|
123
|
+
# @option options [String] :reuse_message (nil) reuse the log message and
|
|
124
|
+
# authorship from the given commit without invoking an editor
|
|
125
|
+
#
|
|
126
|
+
# Alias: `:C`
|
|
127
|
+
#
|
|
128
|
+
# @option options [String] :fixup (nil) create a fixup or amend commit targeting
|
|
129
|
+
# the given commit
|
|
130
|
+
#
|
|
131
|
+
# Pass `<commit>` for a plain "fixup!" commit, `amend:<commit>` to also replace
|
|
132
|
+
# the log message, or `reword:<commit>` to replace only the log message.
|
|
133
|
+
#
|
|
134
|
+
# @option options [String] :squash (nil) construct a "squash!" commit message for
|
|
135
|
+
# use with `git rebase --autosquash`
|
|
136
|
+
#
|
|
137
|
+
# @option options [String] :message (nil) use the given string as the commit message
|
|
138
|
+
#
|
|
139
|
+
# Alias: `:m`
|
|
140
|
+
#
|
|
141
|
+
# @option options [String] :file (nil) read the commit message from the given file;
|
|
142
|
+
# use `-` to read from standard input
|
|
143
|
+
#
|
|
144
|
+
# Alias: `:F`
|
|
145
|
+
#
|
|
146
|
+
# @option options [String] :template (nil) start the editor with the contents of
|
|
147
|
+
# the given file as the commit message template
|
|
148
|
+
#
|
|
149
|
+
# Alias: `:t`
|
|
150
|
+
#
|
|
151
|
+
# @option options [Boolean, nil] :reset_author (nil) when used with `:reuse_message`
|
|
152
|
+
# or `:amend`, declare the committer as the new author
|
|
153
|
+
#
|
|
154
|
+
# @option options [String] :author (nil) override the commit author
|
|
155
|
+
#
|
|
156
|
+
# @option options [String] :date (nil) override the author date
|
|
157
|
+
#
|
|
158
|
+
# @option options [String] :cleanup (nil) how to clean up the commit message before
|
|
159
|
+
# committing; one of `strip`, `whitespace`, `verbatim`, `scissors`, or `default`
|
|
160
|
+
#
|
|
161
|
+
# @option options [String, Array<String>] :trailer (nil) add one or more
|
|
162
|
+
# `<token>[=<value>]` trailers to the commit message
|
|
163
|
+
#
|
|
164
|
+
# @option options [Boolean, nil] :verify (nil) run pre-commit and commit-msg hooks (`--verify`)
|
|
165
|
+
#
|
|
166
|
+
# Alias: `:n`
|
|
167
|
+
#
|
|
168
|
+
# @option options [Boolean, nil] :no_verify (nil) bypass pre-commit and commit-msg hooks (`--no-verify`)
|
|
169
|
+
#
|
|
170
|
+
# @option options [Boolean, nil] :allow_empty (nil) allow committing with no changes
|
|
171
|
+
#
|
|
172
|
+
# @option options [Boolean, nil] :allow_empty_message (nil) allow committing with an
|
|
173
|
+
# empty message
|
|
174
|
+
#
|
|
175
|
+
# @option options [Boolean, nil] :no_post_rewrite (nil) bypass the post-rewrite hook
|
|
176
|
+
#
|
|
177
|
+
# @option options [Boolean, nil] :include (nil) stage the listed paths before
|
|
178
|
+
# committing in addition to already-staged contents
|
|
179
|
+
#
|
|
180
|
+
# Alias: `:i`
|
|
181
|
+
#
|
|
182
|
+
# @option options [Boolean, nil] :only (nil) commit only the listed paths from the
|
|
183
|
+
# working tree, ignoring staged changes for other paths
|
|
184
|
+
#
|
|
185
|
+
# Alias: `:o`
|
|
186
|
+
#
|
|
187
|
+
# @option options [Boolean, nil] :dry_run (nil) do not create a commit; show what
|
|
188
|
+
# would be committed
|
|
189
|
+
#
|
|
190
|
+
# @option options [Boolean, nil] :short (nil) show short-format dry-run output;
|
|
191
|
+
# implies `:dry_run`
|
|
192
|
+
#
|
|
193
|
+
# @option options [Boolean, nil] :branch (nil) show branch and tracking info in
|
|
194
|
+
# short-format dry-run output
|
|
195
|
+
#
|
|
196
|
+
# @option options [Boolean, nil] :porcelain (nil) show porcelain-format dry-run
|
|
197
|
+
# output; implies `:dry_run`
|
|
198
|
+
#
|
|
199
|
+
# @option options [Boolean, nil] :long (nil) show long-format dry-run output;
|
|
200
|
+
# implies `:dry_run`
|
|
201
|
+
#
|
|
202
|
+
# @option options [Boolean, nil] :null (nil) terminate dry-run output entries with
|
|
203
|
+
# NUL instead of LF
|
|
204
|
+
#
|
|
205
|
+
# Alias: `:z`
|
|
206
|
+
#
|
|
207
|
+
# @option options [Boolean, Integer, nil] :verbose (nil) show unified diff between
|
|
208
|
+
# HEAD and what would be committed at the bottom of the commit message template
|
|
209
|
+
#
|
|
210
|
+
# Pass `2` to also show the unified diff between staged and working-tree changes.
|
|
211
|
+
#
|
|
212
|
+
# Alias: `:v`
|
|
213
|
+
#
|
|
214
|
+
# @option options [Boolean, nil] :quiet (nil) suppress commit summary message
|
|
215
|
+
#
|
|
216
|
+
# Alias: `:q`
|
|
217
|
+
#
|
|
218
|
+
# @option options [Boolean, nil] :status (nil) include `git status` output in the
|
|
219
|
+
# commit message template (`--status`)
|
|
220
|
+
#
|
|
221
|
+
# @option options [Boolean, nil] :no_status (nil) omit `git status` output from the
|
|
222
|
+
# commit message template (`--no-status`)
|
|
223
|
+
#
|
|
224
|
+
# @option options [Integer] :unified (nil) generate verbose diff with the given
|
|
225
|
+
# number of context lines
|
|
226
|
+
#
|
|
227
|
+
# Alias: `:U`
|
|
228
|
+
#
|
|
229
|
+
# @option options [Integer] :inter_hunk_context (nil) show context between diff
|
|
230
|
+
# hunks up to the given number of lines (for use with `:verbose`)
|
|
231
|
+
#
|
|
232
|
+
# @option options [Boolean, nil] :signoff (nil) add a `Signed-off-by` trailer to
|
|
233
|
+
# the commit message (`--signoff`)
|
|
234
|
+
#
|
|
235
|
+
# Alias: `:s`
|
|
236
|
+
#
|
|
237
|
+
# @option options [Boolean, nil] :no_signoff (nil) suppress the `Signed-off-by` trailer (`--no-signoff`)
|
|
238
|
+
#
|
|
239
|
+
# @option options [Boolean, String, nil] :gpg_sign (nil) GPG-sign the commit (`--gpg-sign`)
|
|
240
|
+
#
|
|
241
|
+
# When `true`, uses the default key. When a `String`, uses the specified key ID.
|
|
242
|
+
#
|
|
243
|
+
# Alias: `:S`
|
|
244
|
+
#
|
|
245
|
+
# @option options [Boolean, nil] :no_gpg_sign (nil) disable GPG signing, overriding
|
|
246
|
+
# `commit.gpgSign` config (`--no-gpg-sign`)
|
|
247
|
+
#
|
|
248
|
+
# @option options [Boolean, String, nil] :untracked_files (nil) show untracked files
|
|
249
|
+
# in the dry-run status output
|
|
250
|
+
#
|
|
251
|
+
# When `true`, uses git's default mode (`all`). Pass a `String` (`"no"`,
|
|
252
|
+
# `"normal"`, or `"all"`) to set the mode explicitly.
|
|
253
|
+
#
|
|
254
|
+
# Alias: `:u`
|
|
255
|
+
#
|
|
256
|
+
# @option options [String] :pathspec_from_file (nil) read pathspec from the given
|
|
257
|
+
# file instead of the command line
|
|
258
|
+
#
|
|
259
|
+
# @option options [Boolean, nil] :pathspec_file_nul (nil) pathspec elements in
|
|
260
|
+
# `:pathspec_from_file` are NUL-separated instead of newline-separated
|
|
261
|
+
#
|
|
262
|
+
# @return [Git::CommandLineResult] the result of calling `git commit`
|
|
263
|
+
#
|
|
264
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
265
|
+
#
|
|
266
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
267
|
+
#
|
|
268
|
+
# @api public
|
|
269
|
+
#
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
# Implements the `git commit-tree` command
|
|
8
|
+
#
|
|
9
|
+
# Creates a new commit object based on the provided tree object and emits the
|
|
10
|
+
# new commit object id on stdout. The log message is provided via `-m` or `-F`
|
|
11
|
+
# options; multiple instances of either are concatenated as separate paragraphs.
|
|
12
|
+
#
|
|
13
|
+
# @example Typical usage
|
|
14
|
+
# commit_tree = Git::Commands::CommitTree.new(execution_context)
|
|
15
|
+
# commit_tree.call('abc123', m: 'Initial commit')
|
|
16
|
+
# commit_tree.call('abc123', p: %w[parent1 parent2], m: 'Merge')
|
|
17
|
+
# commit_tree.call('abc123', m: 'Signed', gpg_sign: true)
|
|
18
|
+
#
|
|
19
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-commit-tree/2.53.0
|
|
20
|
+
#
|
|
21
|
+
# @see Git::Commands
|
|
22
|
+
#
|
|
23
|
+
# @see https://git-scm.com/docs/git-commit-tree git-commit-tree
|
|
24
|
+
#
|
|
25
|
+
# @api private
|
|
26
|
+
#
|
|
27
|
+
class CommitTree < Git::Commands::Base
|
|
28
|
+
arguments do
|
|
29
|
+
literal 'commit-tree'
|
|
30
|
+
|
|
31
|
+
# Parent commits — each -p adds a parent object
|
|
32
|
+
value_option :p, repeatable: true
|
|
33
|
+
|
|
34
|
+
# GPG signing — -S[<keyid>] / --gpg-sign[=<keyid>] / --no-gpg-sign
|
|
35
|
+
flag_or_value_option %i[gpg_sign S], negatable: true, inline: true
|
|
36
|
+
|
|
37
|
+
# Commit log message paragraphs
|
|
38
|
+
value_option :m, repeatable: true, allow_empty: true
|
|
39
|
+
|
|
40
|
+
# Read commit log message from file(s)
|
|
41
|
+
value_option :F, repeatable: true
|
|
42
|
+
|
|
43
|
+
end_of_options
|
|
44
|
+
|
|
45
|
+
# The tree object to create a commit from
|
|
46
|
+
operand :tree, required: true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @!method call(*, **)
|
|
50
|
+
#
|
|
51
|
+
# @overload call(tree, **options)
|
|
52
|
+
#
|
|
53
|
+
# Execute the `git commit-tree` command
|
|
54
|
+
#
|
|
55
|
+
# @param tree [String] an existing tree object SHA
|
|
56
|
+
#
|
|
57
|
+
# @param options [Hash] command options
|
|
58
|
+
#
|
|
59
|
+
# @option options [String, Array<String>] :p (nil) parent commit
|
|
60
|
+
# object id(s)
|
|
61
|
+
#
|
|
62
|
+
# Each value adds a `-p <parent>` flag. A commit may have zero or
|
|
63
|
+
# more parents. With exactly one parent it is an ordinary commit;
|
|
64
|
+
# with more than one it is a merge commit. Initial (root) commits
|
|
65
|
+
# have no parents.
|
|
66
|
+
#
|
|
67
|
+
# @option options [Boolean, String, nil] :gpg_sign (nil) sign the
|
|
68
|
+
# commit with GPG (`--gpg-sign`)
|
|
69
|
+
#
|
|
70
|
+
# Pass a key-ID string to select the signing key; pass `true` to use
|
|
71
|
+
# the committer identity. Alias: `:S`
|
|
72
|
+
#
|
|
73
|
+
# @option options [Boolean, nil] :no_gpg_sign (nil) countermand commit.gpgSign
|
|
74
|
+
# configuration (`--no-gpg-sign`)
|
|
75
|
+
#
|
|
76
|
+
# @option options [String, Array<String>] :m (nil) a paragraph
|
|
77
|
+
# in the commit log message
|
|
78
|
+
#
|
|
79
|
+
# Can be given more than once; each message becomes its own paragraph.
|
|
80
|
+
#
|
|
81
|
+
# @option options [String, Array<String>] :F (nil) read the commit
|
|
82
|
+
# log message from the given file
|
|
83
|
+
#
|
|
84
|
+
# Use `"-"` to read from standard input. Can be given more than
|
|
85
|
+
# once; each file's content becomes its own paragraph.
|
|
86
|
+
#
|
|
87
|
+
# @return [Git::CommandLineResult] the result of calling
|
|
88
|
+
# `git commit-tree`
|
|
89
|
+
#
|
|
90
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
91
|
+
#
|
|
92
|
+
# @raise [ArgumentError] if the tree operand is missing
|
|
93
|
+
#
|
|
94
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit
|
|
95
|
+
# status
|
|
96
|
+
#
|
|
97
|
+
# @api public
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/base'
|
|
4
|
+
|
|
5
|
+
module Git
|
|
6
|
+
module Commands
|
|
7
|
+
module ConfigOptionSyntax
|
|
8
|
+
# Append a value to a multi-valued config key
|
|
9
|
+
#
|
|
10
|
+
# Wraps `git config --add` to add a new line to a config key without
|
|
11
|
+
# altering existing values.
|
|
12
|
+
#
|
|
13
|
+
# @example Add a value to a multi-valued key
|
|
14
|
+
# cmd = Git::Commands::ConfigOptionSyntax::Add.new(lib)
|
|
15
|
+
# cmd.call('remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*')
|
|
16
|
+
#
|
|
17
|
+
# @note `arguments` block audited against https://git-scm.com/docs/git-config/2.53.0
|
|
18
|
+
#
|
|
19
|
+
# @see Git::Commands::ConfigOptionSyntax
|
|
20
|
+
#
|
|
21
|
+
# @see https://git-scm.com/docs/git-config git-config documentation
|
|
22
|
+
#
|
|
23
|
+
# @api private
|
|
24
|
+
#
|
|
25
|
+
class Add < Git::Commands::Base
|
|
26
|
+
arguments do
|
|
27
|
+
literal 'config'
|
|
28
|
+
literal '--add'
|
|
29
|
+
|
|
30
|
+
# File-scope options
|
|
31
|
+
flag_option :global
|
|
32
|
+
flag_option :system
|
|
33
|
+
flag_option :local
|
|
34
|
+
flag_option :worktree
|
|
35
|
+
value_option %i[file f]
|
|
36
|
+
value_option :blob
|
|
37
|
+
|
|
38
|
+
# Type constraint
|
|
39
|
+
value_option :type, inline: true
|
|
40
|
+
|
|
41
|
+
# Operands
|
|
42
|
+
end_of_options
|
|
43
|
+
operand :name, required: true
|
|
44
|
+
operand :value, required: true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @!method call(*, **)
|
|
48
|
+
#
|
|
49
|
+
# @overload call(name, value, **options)
|
|
50
|
+
#
|
|
51
|
+
# Execute the `git config --add` command
|
|
52
|
+
#
|
|
53
|
+
# @param name [String] the config key name
|
|
54
|
+
#
|
|
55
|
+
# @param value [String] the value to append
|
|
56
|
+
#
|
|
57
|
+
# @param options [Hash] command options
|
|
58
|
+
#
|
|
59
|
+
# @option options [Boolean, nil] :global (nil) write to global config (`~/.gitconfig`)
|
|
60
|
+
#
|
|
61
|
+
# @option options [Boolean, nil] :system (nil) write to system config
|
|
62
|
+
#
|
|
63
|
+
# @option options [Boolean, nil] :local (nil) write to repository config (`.git/config`)
|
|
64
|
+
#
|
|
65
|
+
# @option options [Boolean, nil] :worktree (nil) write to worktree config
|
|
66
|
+
#
|
|
67
|
+
# @option options [String] :file (nil) write to the specified file
|
|
68
|
+
#
|
|
69
|
+
# Alias: :f
|
|
70
|
+
#
|
|
71
|
+
# @option options [String] :blob (nil) read from the specified blob
|
|
72
|
+
#
|
|
73
|
+
# @option options [String] :type (nil) ensure the value conforms to the given type
|
|
74
|
+
#
|
|
75
|
+
# @return [Git::CommandLineResult] the result of calling `git config --add`
|
|
76
|
+
#
|
|
77
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
78
|
+
#
|
|
79
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|