git 5.0.0.beta.2 → 5.0.0.beta.4
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/.dockerignore +27 -0
- data/.github/copilot-instructions.md +3 -8
- data/.github/hooks/bin-setup-on-worktree.json +11 -0
- data/.github/hooks/run-bin-setup-once.sh +14 -0
- data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
- data/.github/skills/command-implementation/REFERENCE.md +34 -33
- data/.github/skills/command-implementation/SKILL.md +5 -4
- data/.github/skills/command-test-conventions/SKILL.md +13 -9
- data/.github/skills/command-yard-documentation/SKILL.md +14 -6
- data/.github/skills/development-workflow/SKILL.md +20 -14
- data/.github/skills/facade-implementation/REFERENCE.md +19 -22
- data/.github/skills/facade-implementation/SKILL.md +0 -5
- data/.github/skills/facade-test-conventions/SKILL.md +4 -7
- data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
- data/.github/skills/make-skill-template/SKILL.md +53 -3
- data/.github/skills/pr-readiness-review/SKILL.md +22 -2
- data/.github/skills/project-context/SKILL.md +16 -23
- data/.github/skills/pull-request-review/SKILL.md +2 -2
- data/.github/skills/rebase/SKILL.md +148 -0
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
- data/.github/skills/resolve-feedback/SKILL.md +288 -0
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
- data/.github/skills/reviewing-skills/SKILL.md +28 -3
- data/.github/skills/test-debugging/SKILL.md +20 -19
- data/.github/skills/yard-documentation/SKILL.md +671 -483
- data/.github/skills/yard-documentation/element-rules.md +162 -0
- data/.github/skills-deprecated/README.md +21 -0
- data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
- data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
- data/.github/workflows/continuous_integration.yml +3 -2
- data/.rubocop.yml +7 -39
- data/.yard-lint.yml +75 -0
- data/CONTRIBUTING.md +186 -174
- data/Gemfile +17 -0
- data/README.md +86 -23
- data/Rakefile +3 -21
- data/UPGRADING.md +219 -70
- data/docker/test/Dockerfile +32 -0
- data/docker/test/docker-compose.yml +0 -0
- data/git.gemspec +3 -4
- data/lib/git/author.rb +20 -1
- data/lib/git/branch.rb +26 -6
- data/lib/git/branch_delete_failure.rb +3 -0
- data/lib/git/branch_delete_result.rb +6 -3
- data/lib/git/branch_info.rb +6 -6
- data/lib/git/command_line/base.rb +6 -13
- data/lib/git/command_line/capturing.rb +67 -10
- data/lib/git/command_line/result.rb +0 -8
- data/lib/git/command_line/streaming.rb +45 -5
- data/lib/git/command_line.rb +4 -3
- data/lib/git/commands/add.rb +61 -53
- data/lib/git/commands/am/abort.rb +2 -2
- data/lib/git/commands/am/apply.rb +109 -98
- data/lib/git/commands/am/continue.rb +2 -2
- data/lib/git/commands/am/quit.rb +2 -2
- data/lib/git/commands/am/retry.rb +4 -2
- data/lib/git/commands/am/show_current_patch.rb +1 -1
- data/lib/git/commands/am/skip.rb +2 -2
- data/lib/git/commands/am.rb +2 -2
- data/lib/git/commands/apply.rb +7 -2
- data/lib/git/commands/archive/list_formats.rb +3 -3
- data/lib/git/commands/archive.rb +7 -2
- data/lib/git/commands/arguments.rb +1370 -359
- data/lib/git/commands/base.rb +111 -13
- data/lib/git/commands/branch/copy.rb +29 -21
- data/lib/git/commands/branch/create.rb +72 -68
- data/lib/git/commands/branch/delete.rb +25 -17
- data/lib/git/commands/branch/list.rb +76 -60
- data/lib/git/commands/branch/move.rb +29 -21
- data/lib/git/commands/branch/set_upstream.rb +8 -8
- data/lib/git/commands/branch/show_current.rb +3 -3
- data/lib/git/commands/branch/unset_upstream.rb +4 -8
- data/lib/git/commands/branch.rb +2 -2
- data/lib/git/commands/cat_file/batch.rb +36 -20
- data/lib/git/commands/cat_file/filtered.rb +12 -12
- data/lib/git/commands/cat_file/raw.rb +13 -13
- data/lib/git/commands/cat_file.rb +4 -4
- data/lib/git/commands/checkout/branch.rb +7 -5
- data/lib/git/commands/checkout/files.rb +5 -4
- data/lib/git/commands/checkout.rb +4 -4
- data/lib/git/commands/checkout_index.rb +5 -4
- data/lib/git/commands/clean.rb +6 -4
- data/lib/git/commands/clone.rb +5 -4
- data/lib/git/commands/commit.rb +5 -4
- data/lib/git/commands/commit_tree.rb +5 -4
- data/lib/git/commands/config_option_syntax/add.rb +7 -4
- data/lib/git/commands/config_option_syntax/get.rb +9 -5
- data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
- data/lib/git/commands/config_option_syntax/list.rb +8 -4
- data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
- data/lib/git/commands/config_option_syntax/set.rb +7 -2
- data/lib/git/commands/config_option_syntax/unset.rb +7 -4
- data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
- data/lib/git/commands/describe.rb +5 -4
- data/lib/git/commands/diff.rb +13 -12
- data/lib/git/commands/diff_files.rb +7 -6
- data/lib/git/commands/diff_index.rb +10 -7
- data/lib/git/commands/fetch.rb +6 -4
- data/lib/git/commands/fsck.rb +6 -4
- data/lib/git/commands/gc.rb +6 -4
- data/lib/git/commands/grep.rb +6 -5
- data/lib/git/commands/init.rb +6 -4
- data/lib/git/commands/log.rb +287 -285
- data/lib/git/commands/ls_files.rb +69 -65
- data/lib/git/commands/ls_remote.rb +62 -56
- data/lib/git/commands/ls_tree.rb +50 -46
- data/lib/git/commands/maintenance/register.rb +25 -23
- data/lib/git/commands/maintenance/run.rb +7 -2
- data/lib/git/commands/maintenance/start.rb +7 -2
- data/lib/git/commands/maintenance/stop.rb +7 -2
- data/lib/git/commands/maintenance/unregister.rb +7 -2
- data/lib/git/commands/merge/abort.rb +2 -2
- data/lib/git/commands/merge/continue.rb +2 -2
- data/lib/git/commands/merge/quit.rb +2 -2
- data/lib/git/commands/merge/start.rb +7 -2
- data/lib/git/commands/merge.rb +2 -2
- data/lib/git/commands/merge_base.rb +7 -2
- data/lib/git/commands/mv.rb +7 -2
- data/lib/git/commands/name_rev.rb +7 -2
- data/lib/git/commands/pull.rb +7 -2
- data/lib/git/commands/push.rb +7 -2
- data/lib/git/commands/read_tree.rb +7 -2
- data/lib/git/commands/remote/add.rb +7 -2
- data/lib/git/commands/remote/get_url.rb +4 -2
- data/lib/git/commands/remote/list.rb +4 -2
- data/lib/git/commands/remote/prune.rb +4 -2
- data/lib/git/commands/remote/remove.rb +4 -2
- data/lib/git/commands/remote/rename.rb +4 -2
- data/lib/git/commands/remote/set_branches.rb +9 -2
- data/lib/git/commands/remote/set_head.rb +12 -5
- data/lib/git/commands/remote/set_url.rb +9 -2
- data/lib/git/commands/remote/set_url_add.rb +11 -2
- data/lib/git/commands/remote/set_url_delete.rb +9 -2
- data/lib/git/commands/remote/show.rb +18 -12
- data/lib/git/commands/remote/update.rb +19 -12
- data/lib/git/commands/remote.rb +2 -2
- data/lib/git/commands/repack.rb +67 -63
- data/lib/git/commands/reset.rb +51 -44
- data/lib/git/commands/rev_parse.rb +135 -128
- data/lib/git/commands/revert/abort.rb +2 -2
- data/lib/git/commands/revert/continue.rb +7 -2
- data/lib/git/commands/revert/quit.rb +2 -2
- data/lib/git/commands/revert/skip.rb +2 -2
- data/lib/git/commands/revert/start.rb +7 -2
- data/lib/git/commands/revert.rb +2 -2
- data/lib/git/commands/rm.rb +35 -36
- data/lib/git/commands/show.rb +1 -1
- data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
- data/lib/git/commands/show_ref/exists.rb +15 -13
- data/lib/git/commands/show_ref/list.rb +39 -35
- data/lib/git/commands/show_ref/verify.rb +29 -27
- data/lib/git/commands/show_ref.rb +4 -4
- data/lib/git/commands/stash/apply.rb +31 -25
- data/lib/git/commands/stash/branch.rb +10 -8
- data/lib/git/commands/stash/clear.rb +7 -5
- data/lib/git/commands/stash/create.rb +10 -8
- data/lib/git/commands/stash/drop.rb +15 -9
- data/lib/git/commands/stash/list.rb +9 -5
- data/lib/git/commands/stash/pop.rb +21 -12
- data/lib/git/commands/stash/push.rb +20 -11
- data/lib/git/commands/stash/show.rb +21 -12
- data/lib/git/commands/stash/store.rb +19 -10
- data/lib/git/commands/stash.rb +2 -2
- data/lib/git/commands/status.rb +7 -2
- data/lib/git/commands/symbolic_ref/delete.rb +18 -14
- data/lib/git/commands/symbolic_ref/read.rb +24 -20
- data/lib/git/commands/symbolic_ref/update.rb +20 -17
- data/lib/git/commands/symbolic_ref.rb +4 -4
- data/lib/git/commands/tag/create.rb +45 -42
- data/lib/git/commands/tag/delete.rb +5 -3
- data/lib/git/commands/tag/list.rb +47 -44
- data/lib/git/commands/tag/verify.rb +12 -12
- data/lib/git/commands/tag.rb +2 -2
- data/lib/git/commands/update_ref/batch.rb +6 -1
- data/lib/git/commands/update_ref/delete.rb +19 -21
- data/lib/git/commands/update_ref/update.rb +22 -25
- data/lib/git/commands/update_ref.rb +4 -4
- data/lib/git/commands/version.rb +14 -11
- data/lib/git/commands/worktree/add.rb +50 -51
- data/lib/git/commands/worktree/list.rb +17 -17
- data/lib/git/commands/worktree/lock.rb +12 -12
- data/lib/git/commands/worktree/move.rb +16 -16
- data/lib/git/commands/worktree/prune.rb +2 -2
- data/lib/git/commands/worktree/remove.rb +2 -2
- data/lib/git/commands/worktree/repair.rb +2 -2
- data/lib/git/commands/worktree/unlock.rb +2 -2
- data/lib/git/commands/write_tree.rb +2 -2
- data/lib/git/commands.rb +4 -3
- data/lib/git/config.rb +47 -1
- data/lib/git/configuring.rb +89 -15
- data/lib/git/detached_head_info.rb +4 -1
- data/lib/git/diff.rb +2 -5
- data/lib/git/diff_file_numstat_info.rb +3 -1
- data/lib/git/diff_file_patch_info.rb +3 -1
- data/lib/git/diff_file_raw_info.rb +3 -1
- data/lib/git/diff_info.rb +8 -15
- data/lib/git/diff_path_status.rb +16 -3
- data/lib/git/diff_result.rb +3 -1
- data/lib/git/diff_stats.rb +15 -0
- data/lib/git/dirstat_info.rb +24 -8
- data/lib/git/encoding_utils.rb +32 -1
- data/lib/git/errors.rb +19 -9
- data/lib/git/escaped_path.rb +55 -3
- data/lib/git/execution_context/repository.rb +15 -0
- data/lib/git/execution_context.rb +76 -74
- data/lib/git/file_ref.rb +6 -3
- data/lib/git/fsck_object.rb +8 -0
- data/lib/git/fsck_result.rb +26 -15
- data/lib/git/log.rb +152 -5
- data/lib/git/object.rb +284 -8
- data/lib/git/parsers/branch.rb +18 -0
- data/lib/git/parsers/cat_file.rb +2 -2
- data/lib/git/parsers/diff.rb +213 -5
- data/lib/git/parsers/fsck.rb +11 -0
- data/lib/git/parsers/ls_remote.rb +1 -1
- data/lib/git/parsers/stash.rb +51 -0
- data/lib/git/parsers/tag.rb +38 -0
- data/lib/git/remote.rb +34 -2
- data/lib/git/repository/branching.rb +23 -21
- data/lib/git/repository/committing.rb +46 -6
- data/lib/git/repository/context_helpers.rb +45 -16
- data/lib/git/repository/diffing.rb +32 -23
- data/lib/git/repository/factories.rb +153 -28
- data/lib/git/repository/inspecting.rb +1 -1
- data/lib/git/repository/logging.rb +169 -30
- data/lib/git/repository/maintenance.rb +1 -1
- data/lib/git/repository/merging.rb +3 -3
- data/lib/git/repository/object_operations.rb +108 -14
- data/lib/git/repository/remote_operations.rb +150 -171
- data/lib/git/repository/shared_private.rb +7 -5
- data/lib/git/repository/staging.rb +36 -12
- data/lib/git/repository/stashing.rb +16 -16
- data/lib/git/repository/status_operations.rb +1 -1
- data/lib/git/repository/worktree_operations.rb +1 -1
- data/lib/git/repository.rb +287 -6
- data/lib/git/stash.rb +16 -21
- data/lib/git/stash_info.rb +4 -4
- data/lib/git/stashes.rb +20 -26
- data/lib/git/status.rb +25 -13
- data/lib/git/tag_delete_failure.rb +3 -0
- data/lib/git/tag_delete_result.rb +6 -3
- data/lib/git/tag_info.rb +1 -0
- data/lib/git/url.rb +12 -5
- data/lib/git/version.rb +6 -4
- data/lib/git/version_constraint.rb +4 -0
- data/lib/git.rb +400 -314
- data/redesign/3_architecture_implementation.md +81 -30
- data/redesign/Phase 4 - Step A.md +6 -0
- data/redesign/Phase 4 - Step B.md +921 -0
- data/redesign/Phase 4 - Step C.md +833 -0
- data/redesign/c1a-public-api-scope.tsv +256 -0
- data/redesign/phase-4-step-b-test-audit.tsv +485 -0
- data/tasks/yard.rake +24 -17
- metadata +24 -58
- data/commitlint.test +0 -4
- data/lib/git/args_builder.rb +0 -103
- data/lib/git/command_line_result.rb +0 -8
- data/lib/git/deprecation.rb +0 -9
- data/lib/git/repository/configuring.rb +0 -351
- data/tasks/test.rake +0 -25
- /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
- /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
data/lib/git/commands/base.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'git/commands/arguments'
|
|
4
|
+
require 'git/version'
|
|
4
5
|
require 'git/version_constraint'
|
|
5
6
|
|
|
6
7
|
module Git
|
|
@@ -52,11 +53,12 @@ module Git
|
|
|
52
53
|
|
|
53
54
|
# Define the command's arguments using the {Arguments} DSL.
|
|
54
55
|
#
|
|
55
|
-
# @
|
|
56
|
+
# @return [void]
|
|
56
57
|
#
|
|
57
58
|
# @raise [ArgumentError] if called more than once on the same class
|
|
58
59
|
#
|
|
59
|
-
# @
|
|
60
|
+
# @yield the block passed to {Arguments.define}
|
|
61
|
+
#
|
|
60
62
|
def arguments(&)
|
|
61
63
|
raise ArgumentError, "arguments already defined for #{name}" if @args_definition
|
|
62
64
|
|
|
@@ -76,9 +78,10 @@ module Git
|
|
|
76
78
|
#
|
|
77
79
|
# @param range [Range] range of accepted exit status values
|
|
78
80
|
#
|
|
81
|
+
# @return [void]
|
|
82
|
+
#
|
|
79
83
|
# @raise [ArgumentError] if range is invalid
|
|
80
84
|
#
|
|
81
|
-
# @return [void]
|
|
82
85
|
def allow_exit_status(range)
|
|
83
86
|
raise ArgumentError, 'allow_exit_status expects a Range' unless range.is_a?(Range)
|
|
84
87
|
unless range.begin.is_a?(Integer) && range.end.is_a?(Integer)
|
|
@@ -96,7 +99,8 @@ module Git
|
|
|
96
99
|
attr_reader :git_version_constraint
|
|
97
100
|
|
|
98
101
|
# @!attribute [r] skip_version_validation?
|
|
99
|
-
#
|
|
102
|
+
#
|
|
103
|
+
# @return [Boolean] whether this command skips version validation
|
|
100
104
|
def skip_version_validation? = !!@skip_version_validation
|
|
101
105
|
|
|
102
106
|
# Declare that this command should skip version validation.
|
|
@@ -105,9 +109,10 @@ module Git
|
|
|
105
109
|
# `git version` command, which cannot validate versions without
|
|
106
110
|
# causing infinite recursion.
|
|
107
111
|
#
|
|
112
|
+
# @return [void]
|
|
113
|
+
#
|
|
108
114
|
# @api private
|
|
109
115
|
#
|
|
110
|
-
# @return [void]
|
|
111
116
|
def skip_version_validation
|
|
112
117
|
@skip_version_validation = true
|
|
113
118
|
end
|
|
@@ -129,11 +134,13 @@ module Git
|
|
|
129
134
|
# requires_git_version before: '2.50.0'
|
|
130
135
|
#
|
|
131
136
|
# @param min [String, nil] minimum version
|
|
137
|
+
#
|
|
132
138
|
# @param before [String, nil] upper bound version (exclusive)
|
|
133
139
|
#
|
|
140
|
+
# @return [void]
|
|
141
|
+
#
|
|
134
142
|
# @raise [ArgumentError] if version format is invalid or called twice
|
|
135
143
|
#
|
|
136
|
-
# @return [void]
|
|
137
144
|
def requires_git_version(min = nil, before: nil)
|
|
138
145
|
raise ArgumentError, 'requires_git_version already declared for this class' if @git_version_constraint
|
|
139
146
|
|
|
@@ -145,6 +152,7 @@ module Git
|
|
|
145
152
|
# Normalize a version constraint to a VersionConstraint
|
|
146
153
|
#
|
|
147
154
|
# @param min [String, nil] minimum version
|
|
155
|
+
#
|
|
148
156
|
# @param before_version [String, nil] upper bound version
|
|
149
157
|
#
|
|
150
158
|
# @return [Git::VersionConstraint] the normalized constraint
|
|
@@ -155,22 +163,43 @@ module Git
|
|
|
155
163
|
raise ArgumentError, 'requires_git_version requires min or before:' unless min || before_version
|
|
156
164
|
|
|
157
165
|
min_version = min ? parse_version(min, 'min') : nil
|
|
158
|
-
before_parsed = before_version ? parse_version(before_version, 'before') : nil
|
|
166
|
+
before_parsed = before_version ? parse_version(before_version, 'before:') : nil
|
|
159
167
|
|
|
160
168
|
Git::VersionConstraint.new(min: min_version, before: before_parsed)
|
|
161
169
|
end
|
|
162
170
|
|
|
171
|
+
# Parse a version string into a Git version object
|
|
172
|
+
#
|
|
173
|
+
# @param version [String] version string to parse
|
|
174
|
+
#
|
|
175
|
+
# @param key_name [String] argument name used in validation errors
|
|
176
|
+
#
|
|
177
|
+
# @return [Git::Version] the parsed version
|
|
178
|
+
#
|
|
179
|
+
# @raise [ArgumentError] if the version format is invalid
|
|
180
|
+
#
|
|
163
181
|
def parse_version(version, key_name)
|
|
164
182
|
validate_version_format!(version, key_name)
|
|
165
183
|
Git::Version.parse(version)
|
|
166
184
|
end
|
|
167
185
|
|
|
186
|
+
# Validate a version string uses the required format
|
|
187
|
+
#
|
|
188
|
+
# @param version [Object] value to validate
|
|
189
|
+
#
|
|
190
|
+
# @param context [String, nil] argument name included in validation errors
|
|
191
|
+
#
|
|
192
|
+
# @return [void]
|
|
193
|
+
#
|
|
194
|
+
# @raise [ArgumentError] if the value is not a `major.minor.patch` version string
|
|
195
|
+
#
|
|
168
196
|
def validate_version_format!(version, context = nil)
|
|
169
197
|
return if version.is_a?(String) && version.match?(/\A\d+\.\d+\.\d+\z/)
|
|
170
198
|
|
|
171
|
-
|
|
199
|
+
subject = context || 'a version'
|
|
172
200
|
raise ArgumentError,
|
|
173
|
-
"requires_git_version expects a 'major.minor.patch' string
|
|
201
|
+
"requires_git_version expects #{subject} to be a 'major.minor.patch' version string, " \
|
|
202
|
+
"got: #{version.inspect}"
|
|
174
203
|
end
|
|
175
204
|
end
|
|
176
205
|
|
|
@@ -202,7 +231,7 @@ module Git
|
|
|
202
231
|
#
|
|
203
232
|
# @param kwargs [Hash] keyword arguments forwarded to {Arguments#bind}
|
|
204
233
|
#
|
|
205
|
-
# @return [Git::
|
|
234
|
+
# @return [Git::CommandLine::Result] the result of calling `git`
|
|
206
235
|
#
|
|
207
236
|
# @raise [ArgumentError] if no arguments definition is declared on the command class
|
|
208
237
|
#
|
|
@@ -219,10 +248,22 @@ module Git
|
|
|
219
248
|
|
|
220
249
|
private
|
|
221
250
|
|
|
251
|
+
# Return the argument definition declared by this command class
|
|
252
|
+
#
|
|
253
|
+
# @return [Git::Commands::Arguments] the argument definition
|
|
254
|
+
#
|
|
255
|
+
# @raise [ArgumentError] if no argument definition is declared
|
|
256
|
+
#
|
|
222
257
|
def args_definition
|
|
223
258
|
self.class.args_definition || raise(ArgumentError, "arguments not defined for #{self.class.name}")
|
|
224
259
|
end
|
|
225
260
|
|
|
261
|
+
# Execute a bound git command through the execution context
|
|
262
|
+
#
|
|
263
|
+
# @param bound [Git::Commands::Arguments::Bound] bound command arguments
|
|
264
|
+
#
|
|
265
|
+
# @return [Git::CommandLine::Result] the command result
|
|
266
|
+
#
|
|
226
267
|
def execute_command(bound)
|
|
227
268
|
exec_opts = execution_opts(bound)
|
|
228
269
|
|
|
@@ -233,6 +274,12 @@ module Git
|
|
|
233
274
|
end
|
|
234
275
|
end
|
|
235
276
|
|
|
277
|
+
# Build execution options for a bound command
|
|
278
|
+
#
|
|
279
|
+
# @param bound [Git::Commands::Arguments::Bound] bound command arguments
|
|
280
|
+
#
|
|
281
|
+
# @return [Hash] execution options for the command line
|
|
282
|
+
#
|
|
236
283
|
def execution_opts(bound)
|
|
237
284
|
caller_env = bound.execution_options.fetch(:env, {}) || {}
|
|
238
285
|
merged_env = caller_env.merge(env)
|
|
@@ -240,6 +287,12 @@ module Git
|
|
|
240
287
|
merged_env.empty? ? opts : opts.merge(env: merged_env)
|
|
241
288
|
end
|
|
242
289
|
|
|
290
|
+
# Build options for captured command output
|
|
291
|
+
#
|
|
292
|
+
# @param exec_opts [Hash] execution options for the command line
|
|
293
|
+
#
|
|
294
|
+
# @return [Hash] options for captured command output
|
|
295
|
+
#
|
|
243
296
|
def capturing_opts(exec_opts)
|
|
244
297
|
opts = exec_opts
|
|
245
298
|
opts = opts.merge(normalize: false) unless normalize_captured_stdout?
|
|
@@ -297,10 +350,22 @@ module Git
|
|
|
297
350
|
{}
|
|
298
351
|
end
|
|
299
352
|
|
|
353
|
+
# Return the allowed exit status range for this command
|
|
354
|
+
#
|
|
355
|
+
# @return [Range] range of accepted exit status values
|
|
356
|
+
#
|
|
300
357
|
def allowed_exit_status_range
|
|
301
358
|
self.class.allowed_exit_status_range || (0..0)
|
|
302
359
|
end
|
|
303
360
|
|
|
361
|
+
# Validate that a command result has an accepted exit status
|
|
362
|
+
#
|
|
363
|
+
# @param result [Git::CommandLine::Result] command result to validate
|
|
364
|
+
#
|
|
365
|
+
# @return [void]
|
|
366
|
+
#
|
|
367
|
+
# @raise [Git::FailedError] if the result exit status is not accepted
|
|
368
|
+
#
|
|
304
369
|
def validate_exit_status!(result)
|
|
305
370
|
raise Git::FailedError, result unless allowed_exit_status_range.include?(result.status.exitstatus)
|
|
306
371
|
end
|
|
@@ -313,6 +378,12 @@ module Git
|
|
|
313
378
|
#
|
|
314
379
|
# Floor check always runs first and fails fast.
|
|
315
380
|
#
|
|
381
|
+
# @param exec_opts [Hash] execution options used to query git version
|
|
382
|
+
#
|
|
383
|
+
# @return [void]
|
|
384
|
+
#
|
|
385
|
+
# @raise [Git::VersionError] if the installed git version is unsupported
|
|
386
|
+
#
|
|
316
387
|
def validate_version!(exec_opts = {})
|
|
317
388
|
return if self.class.skip_version_validation?
|
|
318
389
|
|
|
@@ -325,6 +396,14 @@ module Git
|
|
|
325
396
|
validate_class_version_constraint!(actual_version)
|
|
326
397
|
end
|
|
327
398
|
|
|
399
|
+
# Validate that git satisfies the gem-wide minimum version
|
|
400
|
+
#
|
|
401
|
+
# @param actual_version [Git::Version] installed git version
|
|
402
|
+
#
|
|
403
|
+
# @return [void]
|
|
404
|
+
#
|
|
405
|
+
# @raise [Git::VersionError] if the installed git version is too old
|
|
406
|
+
#
|
|
328
407
|
def validate_floor_version!(actual_version)
|
|
329
408
|
return if actual_version >= Git::MINIMUM_GIT_VERSION
|
|
330
409
|
|
|
@@ -335,6 +414,14 @@ module Git
|
|
|
335
414
|
)
|
|
336
415
|
end
|
|
337
416
|
|
|
417
|
+
# Validate that git satisfies this command class's version constraint
|
|
418
|
+
#
|
|
419
|
+
# @param actual_version [Git::Version] installed git version
|
|
420
|
+
#
|
|
421
|
+
# @return [void]
|
|
422
|
+
#
|
|
423
|
+
# @raise [Git::VersionError] if the installed git version is unsupported
|
|
424
|
+
#
|
|
338
425
|
def validate_class_version_constraint!(actual_version)
|
|
339
426
|
constraint = self.class.git_version_constraint
|
|
340
427
|
return unless constraint
|
|
@@ -365,7 +452,7 @@ module Git
|
|
|
365
452
|
# when `--batch-all-objects` is used and git enumerates objects itself).
|
|
366
453
|
#
|
|
367
454
|
# @example Feed bound object names to a git batch command
|
|
368
|
-
# bound = args_definition.bind(
|
|
455
|
+
# bound = args_definition.bind(*args, **kwargs)
|
|
369
456
|
# stdin_content = Array(bound.objects).map { |object| "#{object}\n" }.join
|
|
370
457
|
# with_stdin(stdin_content) do |reader|
|
|
371
458
|
# @execution_context.command_capturing('cat-file', '--batch-check', in: reader, raise_on_failure: false)
|
|
@@ -373,10 +460,14 @@ module Git
|
|
|
373
460
|
#
|
|
374
461
|
# @param content [String] text to write to the process's stdin
|
|
375
462
|
#
|
|
376
|
-
# @
|
|
463
|
+
# @return [Object] the value returned by the block
|
|
464
|
+
#
|
|
465
|
+
# @yield [reader] the read end of the pipe
|
|
466
|
+
#
|
|
467
|
+
# @yieldparam reader [IO] the read end of the pipe; valid only for the
|
|
377
468
|
# duration of the block
|
|
378
469
|
#
|
|
379
|
-
# @
|
|
470
|
+
# @yieldreturn [Object] the block's return value, which becomes the method's return value
|
|
380
471
|
#
|
|
381
472
|
def with_stdin(content)
|
|
382
473
|
reader, writer = IO.pipe
|
|
@@ -390,6 +481,13 @@ module Git
|
|
|
390
481
|
# Spawns a thread that writes content to writer then closes it.
|
|
391
482
|
# Rescues EPIPE/IOError so the thread exits cleanly when the subprocess
|
|
392
483
|
# closes its stdin early (e.g. on error exit before reading all input).
|
|
484
|
+
#
|
|
485
|
+
# @param content [String] text to write to the pipe
|
|
486
|
+
#
|
|
487
|
+
# @param writer [IO] write end of the pipe
|
|
488
|
+
#
|
|
489
|
+
# @return [Thread] thread writing content to the pipe
|
|
490
|
+
#
|
|
393
491
|
def start_stdin_writer(content, writer)
|
|
394
492
|
Thread.new do
|
|
395
493
|
writer.write(content) unless content.empty?
|
|
@@ -47,47 +47,55 @@ module Git
|
|
|
47
47
|
operand :new_branch, required: true
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
# Executes the git branch --copy command to copy a branch
|
|
51
51
|
#
|
|
52
|
-
#
|
|
52
|
+
# @overload call(new_branch, **options)
|
|
53
53
|
#
|
|
54
|
-
#
|
|
54
|
+
# Copies the current branch to the new_branch
|
|
55
55
|
#
|
|
56
|
-
#
|
|
56
|
+
# @param new_branch [String] the new name for the copied branch
|
|
57
57
|
#
|
|
58
|
-
#
|
|
58
|
+
# @param options [Hash] command options
|
|
59
59
|
#
|
|
60
|
-
#
|
|
60
|
+
# @option options [Boolean, nil] :force (nil) allow copying even if new_branch already
|
|
61
|
+
# exists
|
|
61
62
|
#
|
|
62
|
-
#
|
|
63
|
+
# Alias: :f
|
|
63
64
|
#
|
|
64
|
-
#
|
|
65
|
+
# @return [Git::CommandLine::Result] the result of calling `git branch --copy`
|
|
65
66
|
#
|
|
66
|
-
#
|
|
67
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
67
68
|
#
|
|
68
|
-
#
|
|
69
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
69
70
|
#
|
|
70
|
-
#
|
|
71
|
+
# @api public
|
|
71
72
|
#
|
|
72
|
-
#
|
|
73
|
+
# @overload call(old_branch, new_branch, **options)
|
|
73
74
|
#
|
|
74
|
-
#
|
|
75
|
+
# Copies old_branch to new_branch
|
|
75
76
|
#
|
|
76
|
-
#
|
|
77
|
+
# @param old_branch [String] branch to copy from
|
|
77
78
|
#
|
|
78
|
-
#
|
|
79
|
+
# @param new_branch [String] the new name for the copied branch
|
|
79
80
|
#
|
|
80
|
-
#
|
|
81
|
+
# @param options [Hash] command options
|
|
81
82
|
#
|
|
82
|
-
#
|
|
83
|
+
# @option options [Boolean, nil] :force (nil) allow copying even if new_branch already
|
|
84
|
+
# exists
|
|
83
85
|
#
|
|
84
|
-
#
|
|
86
|
+
# Alias: :f
|
|
85
87
|
#
|
|
86
|
-
#
|
|
88
|
+
# @return [Git::CommandLine::Result] the result of calling `git branch --copy`
|
|
87
89
|
#
|
|
88
|
-
#
|
|
90
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
89
91
|
#
|
|
90
|
-
#
|
|
92
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
93
|
+
#
|
|
94
|
+
# @api public
|
|
95
|
+
#
|
|
96
|
+
def call(*, **)
|
|
97
|
+
super
|
|
98
|
+
end
|
|
91
99
|
end
|
|
92
100
|
end
|
|
93
101
|
end
|
|
@@ -55,118 +55,122 @@ module Git
|
|
|
55
55
|
operand :start_point
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
#
|
|
58
|
+
# @overload call(branch_name, **options)
|
|
59
59
|
#
|
|
60
|
-
#
|
|
60
|
+
# Create a new branch from the current HEAD
|
|
61
61
|
#
|
|
62
|
-
#
|
|
62
|
+
# @param branch_name [String] the name of the branch to create
|
|
63
63
|
#
|
|
64
|
-
#
|
|
64
|
+
# @param options [Hash] command options
|
|
65
65
|
#
|
|
66
|
-
#
|
|
66
|
+
# @option options [Boolean, String, nil] :track (nil) configure upstream tracking for
|
|
67
|
+
# the new branch
|
|
67
68
|
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
69
|
+
# - `true`: Set up tracking using the start-point branch itself (`--track`)
|
|
70
|
+
# - `'direct'`: Same as `true`, explicitly use start-point as upstream (`--track=direct`)
|
|
71
|
+
# - `'inherit'`: Copy upstream configuration from start-point branch (`--track=inherit`)
|
|
70
72
|
#
|
|
71
|
-
#
|
|
72
|
-
# - `'direct'`: Same as `true`, explicitly use start-point as upstream (`--track=direct`)
|
|
73
|
-
# - `'inherit'`: Copy upstream configuration from start-point branch (`--track=inherit`)
|
|
73
|
+
# Alias: :t
|
|
74
74
|
#
|
|
75
|
-
#
|
|
75
|
+
# @option options [Boolean, nil] :no_track (nil) do not set up tracking even if
|
|
76
|
+
# `branch.autoSetupMerge` is set (`--no-track`)
|
|
76
77
|
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
78
|
+
# @option options [Boolean, nil] :force (nil) reset the branch to start point even if
|
|
79
|
+
# it already exists
|
|
79
80
|
#
|
|
80
|
-
#
|
|
81
|
-
# reset the branch to start point even if it already exists
|
|
81
|
+
# Without this, git branch refuses to change an existing branch
|
|
82
82
|
#
|
|
83
|
-
#
|
|
83
|
+
# Alias: :f
|
|
84
84
|
#
|
|
85
|
-
#
|
|
85
|
+
# @option options [Boolean, nil] :recurse_submodules (nil) create the branch in the
|
|
86
|
+
# superproject and all submodules
|
|
86
87
|
#
|
|
87
|
-
#
|
|
88
|
-
# create the branch in the superproject and all submodules
|
|
88
|
+
# This is an experimental feature
|
|
89
89
|
#
|
|
90
|
-
#
|
|
90
|
+
# @option options [Boolean, nil] :quiet (nil) suppress informational messages
|
|
91
91
|
#
|
|
92
|
-
#
|
|
93
|
-
# suppress informational messages
|
|
92
|
+
# Alias: :q
|
|
94
93
|
#
|
|
95
|
-
#
|
|
94
|
+
# @option options [Boolean, nil] :create_reflog (nil) create the branch's reflog
|
|
95
|
+
# (`--create-reflog`)
|
|
96
96
|
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
97
|
+
# Enables date-based sha1 expressions such as `branch@\\{yesterday}`
|
|
98
|
+
# In non-bare repositories, reflogs are usually enabled by default via
|
|
99
|
+
# `core.logAllRefUpdates`
|
|
99
100
|
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
# via `core.logAllRefUpdates`.
|
|
101
|
+
# @option options [Boolean, nil] :no_create_reflog (nil) forcibly disable the
|
|
102
|
+
# branch's reflog (`--no-create-reflog`)
|
|
103
103
|
#
|
|
104
|
-
#
|
|
105
|
-
# forcibly disable the branch's reflog (`--no-create-reflog`)
|
|
104
|
+
# @return [Git::CommandLine::Result] the result of calling `git branch`
|
|
106
105
|
#
|
|
107
|
-
#
|
|
106
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
108
107
|
#
|
|
109
|
-
#
|
|
108
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
110
109
|
#
|
|
111
|
-
#
|
|
110
|
+
# @api public
|
|
112
111
|
#
|
|
113
|
-
#
|
|
112
|
+
# @overload call(branch_name, start_point, **options)
|
|
114
113
|
#
|
|
115
|
-
#
|
|
114
|
+
# Create a new branch from the specified start point
|
|
116
115
|
#
|
|
117
|
-
#
|
|
116
|
+
# @param branch_name [String] the name of the branch to create
|
|
118
117
|
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
118
|
+
# @param start_point [String, nil] the commit, branch, or tag to
|
|
119
|
+
# start the new branch from
|
|
121
120
|
#
|
|
122
|
-
#
|
|
121
|
+
# Can also use `<rev-A>...<rev-B>` syntax for merge base
|
|
123
122
|
#
|
|
124
|
-
#
|
|
123
|
+
# @param options [Hash] command options
|
|
125
124
|
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
125
|
+
# @option options [Boolean, String, nil] :track (nil) configure upstream tracking for
|
|
126
|
+
# the new branch
|
|
128
127
|
#
|
|
129
|
-
#
|
|
130
|
-
#
|
|
131
|
-
#
|
|
128
|
+
# - `true`: Set up tracking using the start-point branch itself (`--track`)
|
|
129
|
+
# - `'direct'`: Same as `true`, explicitly use start-point as upstream (`--track=direct`)
|
|
130
|
+
# - `'inherit'`: Copy upstream configuration from start-point branch (`--track=inherit`)
|
|
132
131
|
#
|
|
133
|
-
#
|
|
132
|
+
# Alias: :t
|
|
134
133
|
#
|
|
135
|
-
#
|
|
136
|
-
#
|
|
134
|
+
# @option options [Boolean, nil] :no_track (nil) do not set up tracking even if
|
|
135
|
+
# `branch.autoSetupMerge` is set (`--no-track`)
|
|
137
136
|
#
|
|
138
|
-
#
|
|
139
|
-
#
|
|
137
|
+
# @option options [Boolean, nil] :force (nil) reset the branch to start point even if
|
|
138
|
+
# it already exists
|
|
140
139
|
#
|
|
141
|
-
#
|
|
140
|
+
# Without this, git branch refuses to change an existing branch
|
|
142
141
|
#
|
|
143
|
-
#
|
|
142
|
+
# Alias: :f
|
|
144
143
|
#
|
|
145
|
-
#
|
|
146
|
-
#
|
|
144
|
+
# @option options [Boolean, nil] :recurse_submodules (nil) create the branch in the
|
|
145
|
+
# superproject and all submodules
|
|
147
146
|
#
|
|
148
|
-
#
|
|
147
|
+
# This is an experimental feature
|
|
149
148
|
#
|
|
150
|
-
#
|
|
151
|
-
# suppress informational messages
|
|
149
|
+
# @option options [Boolean, nil] :quiet (nil) suppress informational messages
|
|
152
150
|
#
|
|
153
|
-
#
|
|
151
|
+
# Alias: :q
|
|
154
152
|
#
|
|
155
|
-
#
|
|
156
|
-
#
|
|
153
|
+
# @option options [Boolean, nil] :create_reflog (nil) create the branch's reflog
|
|
154
|
+
# (`--create-reflog`)
|
|
157
155
|
#
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
#
|
|
156
|
+
# Enables date-based sha1 expressions such as `branch@\\{yesterday}`
|
|
157
|
+
# In non-bare repositories, reflogs are usually enabled by default via
|
|
158
|
+
# `core.logAllRefUpdates`
|
|
161
159
|
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
160
|
+
# @option options [Boolean, nil] :no_create_reflog (nil) forcibly disable the
|
|
161
|
+
# branch's reflog (`--no-create-reflog`)
|
|
164
162
|
#
|
|
165
|
-
#
|
|
163
|
+
# @return [Git::CommandLine::Result] the result of calling `git branch`
|
|
166
164
|
#
|
|
167
|
-
#
|
|
165
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
168
166
|
#
|
|
169
|
-
#
|
|
167
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
168
|
+
#
|
|
169
|
+
# @api public
|
|
170
|
+
#
|
|
171
|
+
def call(*, **)
|
|
172
|
+
super
|
|
173
|
+
end
|
|
170
174
|
end
|
|
171
175
|
end
|
|
172
176
|
end
|
|
@@ -46,34 +46,42 @@ module Git
|
|
|
46
46
|
# git branch --delete exits 1 when one or more branches cannot be deleted
|
|
47
47
|
allow_exit_status 0..1
|
|
48
48
|
|
|
49
|
-
#
|
|
49
|
+
# Executes the git branch --delete command to delete branches
|
|
50
50
|
#
|
|
51
|
-
#
|
|
51
|
+
# @overload call(*branch_name, **options)
|
|
52
52
|
#
|
|
53
|
-
# @
|
|
53
|
+
# @param branch_name [Array<String>] one or more branch names to delete
|
|
54
54
|
#
|
|
55
|
-
#
|
|
55
|
+
# @param options [Hash] command options
|
|
56
56
|
#
|
|
57
|
-
#
|
|
57
|
+
# @option options [Boolean, nil] :force (nil) allow deleting the branch irrespective of
|
|
58
|
+
# its merged status, or whether it even points to a valid commit
|
|
58
59
|
#
|
|
59
|
-
#
|
|
60
|
-
# status, or whether it even points to a valid commit. This is equivalent
|
|
61
|
-
# to the `-D` shortcut (`--delete --force`).
|
|
60
|
+
# Equivalent to the `-D` shortcut (`--delete --force`)
|
|
62
61
|
#
|
|
63
|
-
#
|
|
62
|
+
# Alias: :f
|
|
64
63
|
#
|
|
65
|
-
#
|
|
66
|
-
# with `--delete` to delete remote-tracking branches. Note that this only
|
|
67
|
-
# makes sense if the remote-tracking branches no longer exist in the remote
|
|
68
|
-
# repository or if `git fetch` was configured not to fetch them again.
|
|
64
|
+
# @option options [Boolean, nil] :remotes (nil) delete remote-tracking branches
|
|
69
65
|
#
|
|
70
|
-
#
|
|
66
|
+
# Use this together with `--delete` to remove remote-tracking branches that no
|
|
67
|
+
# longer exist in the remote repository, or if `git fetch` was configured not to
|
|
68
|
+
# fetch them again
|
|
71
69
|
#
|
|
72
|
-
#
|
|
70
|
+
# Alias: :r
|
|
73
71
|
#
|
|
74
|
-
#
|
|
72
|
+
# @return [Git::CommandLine::Result] the result of calling `git branch --delete`
|
|
75
73
|
#
|
|
76
|
-
#
|
|
74
|
+
# @raise [ArgumentError] if no branch names are provided
|
|
75
|
+
#
|
|
76
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
77
|
+
#
|
|
78
|
+
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 1)
|
|
79
|
+
#
|
|
80
|
+
# @api public
|
|
81
|
+
#
|
|
82
|
+
def call(*, **)
|
|
83
|
+
super
|
|
84
|
+
end
|
|
77
85
|
end
|
|
78
86
|
end
|
|
79
87
|
end
|