git 5.0.0.beta.3 → 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.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +27 -0
  3. data/.github/copilot-instructions.md +3 -8
  4. data/.github/hooks/bin-setup-on-worktree.json +11 -0
  5. data/.github/hooks/run-bin-setup-once.sh +14 -0
  6. data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
  7. data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
  8. data/.github/skills/command-implementation/REFERENCE.md +34 -33
  9. data/.github/skills/command-implementation/SKILL.md +5 -4
  10. data/.github/skills/command-test-conventions/SKILL.md +13 -9
  11. data/.github/skills/command-yard-documentation/SKILL.md +14 -6
  12. data/.github/skills/development-workflow/SKILL.md +20 -14
  13. data/.github/skills/facade-implementation/REFERENCE.md +19 -22
  14. data/.github/skills/facade-implementation/SKILL.md +0 -5
  15. data/.github/skills/facade-test-conventions/SKILL.md +4 -7
  16. data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
  17. data/.github/skills/make-skill-template/SKILL.md +53 -3
  18. data/.github/skills/pr-readiness-review/SKILL.md +22 -2
  19. data/.github/skills/project-context/SKILL.md +16 -23
  20. data/.github/skills/pull-request-review/SKILL.md +2 -2
  21. data/.github/skills/rebase/SKILL.md +148 -0
  22. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
  23. data/.github/skills/resolve-feedback/SKILL.md +288 -0
  24. data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
  25. data/.github/skills/reviewing-skills/SKILL.md +28 -3
  26. data/.github/skills/test-debugging/SKILL.md +20 -19
  27. data/.github/skills/yard-documentation/SKILL.md +671 -483
  28. data/.github/skills/yard-documentation/element-rules.md +162 -0
  29. data/.github/skills-deprecated/README.md +21 -0
  30. data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
  31. data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
  32. data/.github/workflows/continuous_integration.yml +3 -2
  33. data/.rubocop.yml +7 -39
  34. data/.yard-lint.yml +75 -0
  35. data/CONTRIBUTING.md +186 -174
  36. data/Gemfile +17 -0
  37. data/README.md +47 -12
  38. data/Rakefile +3 -21
  39. data/UPGRADING.md +219 -70
  40. data/docker/test/Dockerfile +32 -0
  41. data/docker/test/docker-compose.yml +0 -0
  42. data/git.gemspec +3 -4
  43. data/lib/git/author.rb +20 -1
  44. data/lib/git/branch.rb +26 -6
  45. data/lib/git/branch_delete_failure.rb +3 -0
  46. data/lib/git/branch_delete_result.rb +6 -3
  47. data/lib/git/branch_info.rb +6 -6
  48. data/lib/git/command_line/base.rb +6 -13
  49. data/lib/git/command_line/capturing.rb +67 -10
  50. data/lib/git/command_line/result.rb +0 -8
  51. data/lib/git/command_line/streaming.rb +45 -5
  52. data/lib/git/command_line.rb +4 -3
  53. data/lib/git/commands/add.rb +61 -53
  54. data/lib/git/commands/am/abort.rb +2 -2
  55. data/lib/git/commands/am/apply.rb +109 -98
  56. data/lib/git/commands/am/continue.rb +2 -2
  57. data/lib/git/commands/am/quit.rb +2 -2
  58. data/lib/git/commands/am/retry.rb +4 -2
  59. data/lib/git/commands/am/show_current_patch.rb +1 -1
  60. data/lib/git/commands/am/skip.rb +2 -2
  61. data/lib/git/commands/am.rb +2 -2
  62. data/lib/git/commands/apply.rb +7 -2
  63. data/lib/git/commands/archive/list_formats.rb +3 -3
  64. data/lib/git/commands/archive.rb +7 -2
  65. data/lib/git/commands/arguments.rb +1370 -359
  66. data/lib/git/commands/base.rb +111 -13
  67. data/lib/git/commands/branch/copy.rb +29 -21
  68. data/lib/git/commands/branch/create.rb +72 -68
  69. data/lib/git/commands/branch/delete.rb +25 -17
  70. data/lib/git/commands/branch/list.rb +76 -60
  71. data/lib/git/commands/branch/move.rb +29 -21
  72. data/lib/git/commands/branch/set_upstream.rb +8 -8
  73. data/lib/git/commands/branch/show_current.rb +3 -3
  74. data/lib/git/commands/branch/unset_upstream.rb +4 -8
  75. data/lib/git/commands/branch.rb +2 -2
  76. data/lib/git/commands/cat_file/batch.rb +36 -20
  77. data/lib/git/commands/cat_file/filtered.rb +12 -12
  78. data/lib/git/commands/cat_file/raw.rb +13 -13
  79. data/lib/git/commands/cat_file.rb +4 -4
  80. data/lib/git/commands/checkout/branch.rb +7 -5
  81. data/lib/git/commands/checkout/files.rb +5 -4
  82. data/lib/git/commands/checkout.rb +4 -4
  83. data/lib/git/commands/checkout_index.rb +5 -4
  84. data/lib/git/commands/clean.rb +6 -4
  85. data/lib/git/commands/clone.rb +5 -4
  86. data/lib/git/commands/commit.rb +5 -4
  87. data/lib/git/commands/commit_tree.rb +5 -4
  88. data/lib/git/commands/config_option_syntax/add.rb +7 -4
  89. data/lib/git/commands/config_option_syntax/get.rb +9 -5
  90. data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
  91. data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
  92. data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
  93. data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
  94. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
  95. data/lib/git/commands/config_option_syntax/list.rb +8 -4
  96. data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
  97. data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
  98. data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
  99. data/lib/git/commands/config_option_syntax/set.rb +7 -2
  100. data/lib/git/commands/config_option_syntax/unset.rb +7 -4
  101. data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
  102. data/lib/git/commands/describe.rb +5 -4
  103. data/lib/git/commands/diff.rb +13 -12
  104. data/lib/git/commands/diff_files.rb +7 -6
  105. data/lib/git/commands/diff_index.rb +10 -7
  106. data/lib/git/commands/fetch.rb +6 -4
  107. data/lib/git/commands/fsck.rb +6 -4
  108. data/lib/git/commands/gc.rb +6 -4
  109. data/lib/git/commands/grep.rb +6 -5
  110. data/lib/git/commands/init.rb +6 -4
  111. data/lib/git/commands/log.rb +287 -285
  112. data/lib/git/commands/ls_files.rb +69 -65
  113. data/lib/git/commands/ls_remote.rb +62 -56
  114. data/lib/git/commands/ls_tree.rb +50 -46
  115. data/lib/git/commands/maintenance/register.rb +25 -23
  116. data/lib/git/commands/maintenance/run.rb +7 -2
  117. data/lib/git/commands/maintenance/start.rb +7 -2
  118. data/lib/git/commands/maintenance/stop.rb +7 -2
  119. data/lib/git/commands/maintenance/unregister.rb +7 -2
  120. data/lib/git/commands/merge/abort.rb +2 -2
  121. data/lib/git/commands/merge/continue.rb +2 -2
  122. data/lib/git/commands/merge/quit.rb +2 -2
  123. data/lib/git/commands/merge/start.rb +7 -2
  124. data/lib/git/commands/merge.rb +2 -2
  125. data/lib/git/commands/merge_base.rb +7 -2
  126. data/lib/git/commands/mv.rb +7 -2
  127. data/lib/git/commands/name_rev.rb +7 -2
  128. data/lib/git/commands/pull.rb +7 -2
  129. data/lib/git/commands/push.rb +7 -2
  130. data/lib/git/commands/read_tree.rb +7 -2
  131. data/lib/git/commands/remote/add.rb +7 -2
  132. data/lib/git/commands/remote/get_url.rb +4 -2
  133. data/lib/git/commands/remote/list.rb +4 -2
  134. data/lib/git/commands/remote/prune.rb +4 -2
  135. data/lib/git/commands/remote/remove.rb +4 -2
  136. data/lib/git/commands/remote/rename.rb +4 -2
  137. data/lib/git/commands/remote/set_branches.rb +9 -2
  138. data/lib/git/commands/remote/set_head.rb +12 -5
  139. data/lib/git/commands/remote/set_url.rb +9 -2
  140. data/lib/git/commands/remote/set_url_add.rb +11 -2
  141. data/lib/git/commands/remote/set_url_delete.rb +9 -2
  142. data/lib/git/commands/remote/show.rb +18 -12
  143. data/lib/git/commands/remote/update.rb +19 -12
  144. data/lib/git/commands/remote.rb +2 -2
  145. data/lib/git/commands/repack.rb +67 -63
  146. data/lib/git/commands/reset.rb +51 -44
  147. data/lib/git/commands/rev_parse.rb +135 -128
  148. data/lib/git/commands/revert/abort.rb +2 -2
  149. data/lib/git/commands/revert/continue.rb +7 -2
  150. data/lib/git/commands/revert/quit.rb +2 -2
  151. data/lib/git/commands/revert/skip.rb +2 -2
  152. data/lib/git/commands/revert/start.rb +7 -2
  153. data/lib/git/commands/revert.rb +2 -2
  154. data/lib/git/commands/rm.rb +35 -36
  155. data/lib/git/commands/show.rb +1 -1
  156. data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
  157. data/lib/git/commands/show_ref/exists.rb +15 -13
  158. data/lib/git/commands/show_ref/list.rb +39 -35
  159. data/lib/git/commands/show_ref/verify.rb +29 -27
  160. data/lib/git/commands/show_ref.rb +4 -4
  161. data/lib/git/commands/stash/apply.rb +31 -25
  162. data/lib/git/commands/stash/branch.rb +10 -8
  163. data/lib/git/commands/stash/clear.rb +7 -5
  164. data/lib/git/commands/stash/create.rb +10 -8
  165. data/lib/git/commands/stash/drop.rb +15 -9
  166. data/lib/git/commands/stash/list.rb +9 -5
  167. data/lib/git/commands/stash/pop.rb +21 -12
  168. data/lib/git/commands/stash/push.rb +20 -11
  169. data/lib/git/commands/stash/show.rb +21 -12
  170. data/lib/git/commands/stash/store.rb +19 -10
  171. data/lib/git/commands/stash.rb +2 -2
  172. data/lib/git/commands/status.rb +7 -2
  173. data/lib/git/commands/symbolic_ref/delete.rb +18 -14
  174. data/lib/git/commands/symbolic_ref/read.rb +24 -20
  175. data/lib/git/commands/symbolic_ref/update.rb +20 -17
  176. data/lib/git/commands/symbolic_ref.rb +4 -4
  177. data/lib/git/commands/tag/create.rb +45 -42
  178. data/lib/git/commands/tag/delete.rb +5 -3
  179. data/lib/git/commands/tag/list.rb +47 -44
  180. data/lib/git/commands/tag/verify.rb +12 -12
  181. data/lib/git/commands/tag.rb +2 -2
  182. data/lib/git/commands/update_ref/batch.rb +6 -1
  183. data/lib/git/commands/update_ref/delete.rb +19 -21
  184. data/lib/git/commands/update_ref/update.rb +22 -25
  185. data/lib/git/commands/update_ref.rb +4 -4
  186. data/lib/git/commands/version.rb +14 -11
  187. data/lib/git/commands/worktree/add.rb +50 -51
  188. data/lib/git/commands/worktree/list.rb +17 -17
  189. data/lib/git/commands/worktree/lock.rb +12 -12
  190. data/lib/git/commands/worktree/move.rb +16 -16
  191. data/lib/git/commands/worktree/prune.rb +2 -2
  192. data/lib/git/commands/worktree/remove.rb +2 -2
  193. data/lib/git/commands/worktree/repair.rb +2 -2
  194. data/lib/git/commands/worktree/unlock.rb +2 -2
  195. data/lib/git/commands/write_tree.rb +2 -2
  196. data/lib/git/commands.rb +4 -3
  197. data/lib/git/config.rb +47 -1
  198. data/lib/git/configuring.rb +89 -15
  199. data/lib/git/detached_head_info.rb +4 -1
  200. data/lib/git/diff.rb +2 -5
  201. data/lib/git/diff_file_numstat_info.rb +3 -1
  202. data/lib/git/diff_file_patch_info.rb +3 -1
  203. data/lib/git/diff_file_raw_info.rb +3 -1
  204. data/lib/git/diff_info.rb +8 -15
  205. data/lib/git/diff_path_status.rb +16 -3
  206. data/lib/git/diff_result.rb +3 -1
  207. data/lib/git/diff_stats.rb +15 -0
  208. data/lib/git/dirstat_info.rb +24 -8
  209. data/lib/git/encoding_utils.rb +32 -1
  210. data/lib/git/errors.rb +19 -9
  211. data/lib/git/escaped_path.rb +55 -3
  212. data/lib/git/execution_context/repository.rb +15 -0
  213. data/lib/git/execution_context.rb +76 -74
  214. data/lib/git/file_ref.rb +6 -3
  215. data/lib/git/fsck_object.rb +8 -0
  216. data/lib/git/fsck_result.rb +26 -15
  217. data/lib/git/log.rb +152 -5
  218. data/lib/git/object.rb +284 -8
  219. data/lib/git/parsers/branch.rb +18 -0
  220. data/lib/git/parsers/cat_file.rb +2 -2
  221. data/lib/git/parsers/diff.rb +213 -5
  222. data/lib/git/parsers/fsck.rb +11 -0
  223. data/lib/git/parsers/ls_remote.rb +1 -1
  224. data/lib/git/parsers/stash.rb +51 -0
  225. data/lib/git/parsers/tag.rb +38 -0
  226. data/lib/git/remote.rb +34 -2
  227. data/lib/git/repository/branching.rb +23 -21
  228. data/lib/git/repository/committing.rb +46 -6
  229. data/lib/git/repository/context_helpers.rb +45 -16
  230. data/lib/git/repository/diffing.rb +32 -23
  231. data/lib/git/repository/factories.rb +153 -28
  232. data/lib/git/repository/inspecting.rb +1 -1
  233. data/lib/git/repository/logging.rb +169 -30
  234. data/lib/git/repository/maintenance.rb +1 -1
  235. data/lib/git/repository/merging.rb +3 -3
  236. data/lib/git/repository/object_operations.rb +108 -14
  237. data/lib/git/repository/remote_operations.rb +150 -171
  238. data/lib/git/repository/shared_private.rb +7 -5
  239. data/lib/git/repository/staging.rb +36 -12
  240. data/lib/git/repository/stashing.rb +16 -16
  241. data/lib/git/repository/status_operations.rb +1 -1
  242. data/lib/git/repository/worktree_operations.rb +1 -1
  243. data/lib/git/repository.rb +123 -63
  244. data/lib/git/stash.rb +16 -21
  245. data/lib/git/stash_info.rb +4 -4
  246. data/lib/git/stashes.rb +20 -26
  247. data/lib/git/status.rb +21 -7
  248. data/lib/git/tag_delete_failure.rb +3 -0
  249. data/lib/git/tag_delete_result.rb +6 -3
  250. data/lib/git/tag_info.rb +1 -0
  251. data/lib/git/url.rb +12 -5
  252. data/lib/git/version.rb +6 -4
  253. data/lib/git/version_constraint.rb +4 -0
  254. data/lib/git.rb +398 -314
  255. data/redesign/3_architecture_implementation.md +59 -29
  256. data/redesign/Phase 4 - Step B.md +921 -0
  257. data/redesign/Phase 4 - Step C.md +833 -0
  258. data/redesign/c1a-public-api-scope.tsv +256 -0
  259. data/redesign/phase-4-step-b-test-audit.tsv +485 -0
  260. data/tasks/yard.rake +24 -17
  261. metadata +24 -57
  262. data/commitlint.test +0 -4
  263. data/lib/git/args_builder.rb +0 -103
  264. data/lib/git/command_line_result.rb +0 -8
  265. data/lib/git/deprecation.rb +0 -9
  266. data/tasks/test.rake +0 -25
  267. /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
  268. /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
@@ -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
- # @yield the block passed to {Arguments.define}
56
+ # @return [void]
56
57
  #
57
58
  # @raise [ArgumentError] if called more than once on the same class
58
59
  #
59
- # @return [void]
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
- # @return [Boolean] whether this command skips version validation
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
- ctx = context ? " for #{context}" : ''
199
+ subject = context || 'a version'
172
200
  raise ArgumentError,
173
- "requires_git_version expects a 'major.minor.patch' string#{ctx}, got: #{version.inspect}"
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::CommandLineResult] the result of calling `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
- # @yield [reader [IO]] the read end of the pipe; valid only for the
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
- # @return [Object] the value returned by the block
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
- # @!method call(*, **)
50
+ # Executes the git branch --copy command to copy a branch
51
51
  #
52
- # Execute the git branch --copy command to copy a branch
52
+ # @overload call(new_branch, **options)
53
53
  #
54
- # @overload call(new_branch, **options)
54
+ # Copies the current branch to the new_branch
55
55
  #
56
- # Copies the current branch to the new_branch
56
+ # @param new_branch [String] the new name for the copied branch
57
57
  #
58
- # @param new_branch [String] the new name for the copied branch
58
+ # @param options [Hash] command options
59
59
  #
60
- # @param options [Hash] command options
60
+ # @option options [Boolean, nil] :force (nil) allow copying even if new_branch already
61
+ # exists
61
62
  #
62
- # @option options [Boolean, nil] :force (nil) allow copying even if new_branch already exists
63
+ # Alias: :f
63
64
  #
64
- # Alias: :f
65
+ # @return [Git::CommandLine::Result] the result of calling `git branch --copy`
65
66
  #
66
- # @return [Git::CommandLineResult] the result of calling `git branch --copy`
67
+ # @raise [ArgumentError] if unsupported options are provided
67
68
  #
68
- # @raise [ArgumentError] if unsupported options are provided
69
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
69
70
  #
70
- # @raise [Git::FailedError] if git exits with a non-zero exit status
71
+ # @api public
71
72
  #
72
- # @overload call(old_branch, new_branch, **options)
73
+ # @overload call(old_branch, new_branch, **options)
73
74
  #
74
- # Copies old_branch to new_branch
75
+ # Copies old_branch to new_branch
75
76
  #
76
- # @param old_branch [String] branch to copy from
77
+ # @param old_branch [String] branch to copy from
77
78
  #
78
- # @param new_branch [String] the new name for the copied branch
79
+ # @param new_branch [String] the new name for the copied branch
79
80
  #
80
- # @param options [Hash] command options
81
+ # @param options [Hash] command options
81
82
  #
82
- # @option options [Boolean, nil] :force (nil) allow copying even if new_branch already exists
83
+ # @option options [Boolean, nil] :force (nil) allow copying even if new_branch already
84
+ # exists
83
85
  #
84
- # Alias: :f
86
+ # Alias: :f
85
87
  #
86
- # @return [Git::CommandLineResult] the result of calling `git branch --copy`
88
+ # @return [Git::CommandLine::Result] the result of calling `git branch --copy`
87
89
  #
88
- # @raise [ArgumentError] if unsupported options are provided
90
+ # @raise [ArgumentError] if unsupported options are provided
89
91
  #
90
- # @raise [Git::FailedError] if git exits with a non-zero exit status
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
- # @!method call(*, **)
58
+ # @overload call(branch_name, **options)
59
59
  #
60
- # @overload call(branch_name, **options)
60
+ # Create a new branch from the current HEAD
61
61
  #
62
- # Create a new branch from the current HEAD
62
+ # @param branch_name [String] the name of the branch to create
63
63
  #
64
- # @param branch_name [String] the name of the branch to create
64
+ # @param options [Hash] command options
65
65
  #
66
- # @param options [Hash] command options
66
+ # @option options [Boolean, String, nil] :track (nil) configure upstream tracking for
67
+ # the new branch
67
68
  #
68
- # @option options [Boolean, String, nil] :track (nil)
69
- # configure upstream tracking for the new branch
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
- # - `true`: Set up tracking using the start-point branch itself (`--track`)
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
- # Alias: :t
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
- # @option options [Boolean, nil] :no_track (nil)
78
- # do not set up tracking even if `branch.autoSetupMerge` is set (`--no-track`)
78
+ # @option options [Boolean, nil] :force (nil) reset the branch to start point even if
79
+ # it already exists
79
80
  #
80
- # @option options [Boolean, nil] :force (nil)
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
- # Without this, git branch refuses to change an existing branch.
83
+ # Alias: :f
84
84
  #
85
- # Alias: :f
85
+ # @option options [Boolean, nil] :recurse_submodules (nil) create the branch in the
86
+ # superproject and all submodules
86
87
  #
87
- # @option options [Boolean, nil] :recurse_submodules (nil)
88
- # create the branch in the superproject and all submodules
88
+ # This is an experimental feature
89
89
  #
90
- # This is an experimental feature.
90
+ # @option options [Boolean, nil] :quiet (nil) suppress informational messages
91
91
  #
92
- # @option options [Boolean, nil] :quiet (nil)
93
- # suppress informational messages
92
+ # Alias: :q
94
93
  #
95
- # Alias: :q
94
+ # @option options [Boolean, nil] :create_reflog (nil) create the branch's reflog
95
+ # (`--create-reflog`)
96
96
  #
97
- # @option options [Boolean, nil] :create_reflog (nil)
98
- # create the branch's reflog (`--create-reflog`)
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
- # Enables date-based sha1 expressions such as `branch@{yesterday}`.
101
- # In non-bare repositories, reflogs are usually enabled by default
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
- # @option options [Boolean, nil] :no_create_reflog (nil)
105
- # forcibly disable the branch's reflog (`--no-create-reflog`)
104
+ # @return [Git::CommandLine::Result] the result of calling `git branch`
106
105
  #
107
- # @return [Git::CommandLineResult] the result of calling `git branch`
106
+ # @raise [ArgumentError] if unsupported options are provided
108
107
  #
109
- # @raise [ArgumentError] if unsupported options are provided
108
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
110
109
  #
111
- # @raise [Git::FailedError] if git exits with a non-zero exit status
110
+ # @api public
112
111
  #
113
- # @overload call(branch_name, start_point, **options)
112
+ # @overload call(branch_name, start_point, **options)
114
113
  #
115
- # Create a new branch from the specified start point
114
+ # Create a new branch from the specified start point
116
115
  #
117
- # @param branch_name [String] the name of the branch to create
116
+ # @param branch_name [String] the name of the branch to create
118
117
  #
119
- # @param start_point [String, nil] the commit, branch, or tag to
120
- # start the new branch from
118
+ # @param start_point [String, nil] the commit, branch, or tag to
119
+ # start the new branch from
121
120
  #
122
- # Can also use `<rev-A>...<rev-B>` syntax for merge base.
121
+ # Can also use `<rev-A>...<rev-B>` syntax for merge base
123
122
  #
124
- # @param options [Hash] command options
123
+ # @param options [Hash] command options
125
124
  #
126
- # @option options [Boolean, String, nil] :track (nil)
127
- # configure upstream tracking for the new branch
125
+ # @option options [Boolean, String, nil] :track (nil) configure upstream tracking for
126
+ # the new branch
128
127
  #
129
- # - `true`: Set up tracking using the start-point branch itself (`--track`)
130
- # - `'direct'`: Same as `true`, explicitly use start-point as upstream (`--track=direct`)
131
- # - `'inherit'`: Copy upstream configuration from start-point branch (`--track=inherit`)
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
- # Alias: :t
132
+ # Alias: :t
134
133
  #
135
- # @option options [Boolean, nil] :no_track (nil)
136
- # do not set up tracking even if `branch.autoSetupMerge` is set (`--no-track`)
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
- # @option options [Boolean, nil] :force (nil)
139
- # reset the branch to start point even if it already exists
137
+ # @option options [Boolean, nil] :force (nil) reset the branch to start point even if
138
+ # it already exists
140
139
  #
141
- # Without this, git branch refuses to change an existing branch.
140
+ # Without this, git branch refuses to change an existing branch
142
141
  #
143
- # Alias: :f
142
+ # Alias: :f
144
143
  #
145
- # @option options [Boolean, nil] :recurse_submodules (nil)
146
- # create the branch in the superproject and all submodules
144
+ # @option options [Boolean, nil] :recurse_submodules (nil) create the branch in the
145
+ # superproject and all submodules
147
146
  #
148
- # This is an experimental feature.
147
+ # This is an experimental feature
149
148
  #
150
- # @option options [Boolean, nil] :quiet (nil)
151
- # suppress informational messages
149
+ # @option options [Boolean, nil] :quiet (nil) suppress informational messages
152
150
  #
153
- # Alias: :q
151
+ # Alias: :q
154
152
  #
155
- # @option options [Boolean, nil] :create_reflog (nil)
156
- # create the branch's reflog (`--create-reflog`)
153
+ # @option options [Boolean, nil] :create_reflog (nil) create the branch's reflog
154
+ # (`--create-reflog`)
157
155
  #
158
- # Enables date-based sha1 expressions such as `branch@{yesterday}`.
159
- # In non-bare repositories, reflogs are usually enabled by default
160
- # via `core.logAllRefUpdates`.
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
- # @option options [Boolean, nil] :no_create_reflog (nil)
163
- # forcibly disable the branch's reflog (`--no-create-reflog`)
160
+ # @option options [Boolean, nil] :no_create_reflog (nil) forcibly disable the
161
+ # branch's reflog (`--no-create-reflog`)
164
162
  #
165
- # @return [Git::CommandLineResult] the result of calling `git branch`
163
+ # @return [Git::CommandLine::Result] the result of calling `git branch`
166
164
  #
167
- # @raise [ArgumentError] if unsupported options are provided
165
+ # @raise [ArgumentError] if unsupported options are provided
168
166
  #
169
- # @raise [Git::FailedError] if git exits with a non-zero exit status
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
- # @!method call(*, **)
49
+ # Executes the git branch --delete command to delete branches
50
50
  #
51
- # Execute the git branch --delete command to delete branches
51
+ # @overload call(*branch_name, **options)
52
52
  #
53
- # @overload call(*branch_name, **options)
53
+ # @param branch_name [Array<String>] one or more branch names to delete
54
54
  #
55
- # @param branch_name [Array<String>] One or more branch names to delete.
55
+ # @param options [Hash] command options
56
56
  #
57
- # @param options [Hash] command options
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
- # @option options [Boolean, nil] :force (nil) allow deleting the branch irrespective of its merged
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
- # Alias: :f
62
+ # Alias: :f
64
63
  #
65
- # @option options [Boolean, nil] :remotes (nil) delete remote-tracking branches. Use this together
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
- # Alias: :r
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
- # @return [Git::CommandLineResult] the result of calling `git branch --delete`
70
+ # Alias: :r
73
71
  #
74
- # @raise [ArgumentError] if no branch names are provided
72
+ # @return [Git::CommandLine::Result] the result of calling `git branch --delete`
75
73
  #
76
- # @raise [Git::FailedError] if git exits outside the allowed range (exit code > 1)
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