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.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/.github/copilot-instructions.md +67 -2705
  3. data/.github/pull_request_template.md +3 -1
  4. data/.github/skills/breaking-change-analysis/SKILL.md +102 -0
  5. data/.github/skills/ci-cd-troubleshooting/SKILL.md +264 -0
  6. data/.github/skills/command-implementation/REFERENCE.md +993 -0
  7. data/.github/skills/command-implementation/SKILL.md +229 -0
  8. data/.github/skills/command-test-conventions/SKILL.md +660 -0
  9. data/.github/skills/command-yard-documentation/SKILL.md +426 -0
  10. data/.github/skills/dependency-management/SKILL.md +72 -0
  11. data/.github/skills/development-workflow/SKILL.md +506 -0
  12. data/.github/skills/extract-command-from-lib/SKILL.md +487 -0
  13. data/.github/skills/extract-facade-from-base-lib/SKILL.md +586 -0
  14. data/.github/skills/facade-implementation/REFERENCE.md +840 -0
  15. data/.github/skills/facade-implementation/SKILL.md +260 -0
  16. data/.github/skills/facade-test-conventions/SKILL.md +380 -0
  17. data/.github/skills/facade-yard-documentation/SKILL.md +429 -0
  18. data/.github/skills/make-skill-template/SKILL.md +176 -0
  19. data/.github/skills/pr-readiness-review/SKILL.md +185 -0
  20. data/.github/skills/project-context/SKILL.md +313 -0
  21. data/.github/skills/pull-request-review/SKILL.md +168 -0
  22. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +131 -0
  23. data/.github/skills/release-management/SKILL.md +125 -0
  24. data/.github/skills/review-arguments-dsl/CHECKLIST.md +788 -0
  25. data/.github/skills/review-arguments-dsl/SKILL.md +214 -0
  26. data/.github/skills/review-backward-compatibility/SKILL.md +275 -0
  27. data/.github/skills/review-cross-command-consistency/SKILL.md +139 -0
  28. data/.github/skills/reviewing-skills/SKILL.md +189 -0
  29. data/.github/skills/rspec-unit-testing-standards/SKILL.md +639 -0
  30. data/.github/skills/tdd-refactor-step/SKILL.md +236 -0
  31. data/.github/skills/test-debugging/SKILL.md +160 -0
  32. data/.github/skills/yard-documentation/SKILL.md +793 -0
  33. data/.github/workflows/continuous_integration.yml +3 -2
  34. data/.github/workflows/enforce_conventional_commits.yml +1 -1
  35. data/.github/workflows/experimental_continuous_integration.yml +2 -2
  36. data/.github/workflows/release.yml +3 -4
  37. data/.gitignore +8 -0
  38. data/.husky/pre-commit +13 -0
  39. data/.release-please-manifest.json +1 -1
  40. data/.rspec +3 -0
  41. data/.rubocop.yml +7 -3
  42. data/.rubocop_todo.yml +23 -5
  43. data/.yardopts +1 -0
  44. data/CHANGELOG.md +0 -40
  45. data/CONTRIBUTING.md +694 -53
  46. data/README.md +17 -5
  47. data/Rakefile +61 -9
  48. data/commitlint.test +4 -0
  49. data/git.gemspec +14 -8
  50. data/lib/git/args_builder.rb +0 -8
  51. data/lib/git/base.rb +486 -410
  52. data/lib/git/branch.rb +380 -43
  53. data/lib/git/branch_delete_failure.rb +31 -0
  54. data/lib/git/branch_delete_result.rb +63 -0
  55. data/lib/git/branch_info.rb +178 -0
  56. data/lib/git/branches.rb +130 -24
  57. data/lib/git/command_line/base.rb +245 -0
  58. data/lib/git/command_line/capturing.rb +249 -0
  59. data/lib/git/command_line/result.rb +96 -0
  60. data/lib/git/command_line/streaming.rb +194 -0
  61. data/lib/git/command_line.rb +43 -322
  62. data/lib/git/command_line_result.rb +4 -88
  63. data/lib/git/commands/add.rb +131 -0
  64. data/lib/git/commands/am/abort.rb +43 -0
  65. data/lib/git/commands/am/apply.rb +252 -0
  66. data/lib/git/commands/am/continue.rb +43 -0
  67. data/lib/git/commands/am/quit.rb +43 -0
  68. data/lib/git/commands/am/retry.rb +47 -0
  69. data/lib/git/commands/am/show_current_patch.rb +64 -0
  70. data/lib/git/commands/am/skip.rb +42 -0
  71. data/lib/git/commands/am.rb +33 -0
  72. data/lib/git/commands/apply.rb +237 -0
  73. data/lib/git/commands/archive/list_formats.rb +46 -0
  74. data/lib/git/commands/archive.rb +140 -0
  75. data/lib/git/commands/arguments.rb +3510 -0
  76. data/lib/git/commands/base.rb +403 -0
  77. data/lib/git/commands/branch/copy.rb +94 -0
  78. data/lib/git/commands/branch/create.rb +173 -0
  79. data/lib/git/commands/branch/delete.rb +80 -0
  80. data/lib/git/commands/branch/list.rb +162 -0
  81. data/lib/git/commands/branch/move.rb +94 -0
  82. data/lib/git/commands/branch/set_upstream.rb +86 -0
  83. data/lib/git/commands/branch/show_current.rb +49 -0
  84. data/lib/git/commands/branch/unset_upstream.rb +57 -0
  85. data/lib/git/commands/branch.rb +34 -0
  86. data/lib/git/commands/cat_file/batch.rb +364 -0
  87. data/lib/git/commands/cat_file/filtered.rb +105 -0
  88. data/lib/git/commands/cat_file/raw.rb +210 -0
  89. data/lib/git/commands/cat_file.rb +49 -0
  90. data/lib/git/commands/checkout/branch.rb +151 -0
  91. data/lib/git/commands/checkout/files.rb +115 -0
  92. data/lib/git/commands/checkout.rb +38 -0
  93. data/lib/git/commands/checkout_index.rb +105 -0
  94. data/lib/git/commands/clean.rb +100 -0
  95. data/lib/git/commands/clone.rb +240 -0
  96. data/lib/git/commands/commit.rb +272 -0
  97. data/lib/git/commands/commit_tree.rb +100 -0
  98. data/lib/git/commands/config_option_syntax/add.rb +83 -0
  99. data/lib/git/commands/config_option_syntax/get.rb +117 -0
  100. data/lib/git/commands/config_option_syntax/get_all.rb +115 -0
  101. data/lib/git/commands/config_option_syntax/get_color.rb +91 -0
  102. data/lib/git/commands/config_option_syntax/get_color_bool.rb +93 -0
  103. data/lib/git/commands/config_option_syntax/get_regexp.rb +115 -0
  104. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +102 -0
  105. data/lib/git/commands/config_option_syntax/list.rb +107 -0
  106. data/lib/git/commands/config_option_syntax/remove_section.rb +74 -0
  107. data/lib/git/commands/config_option_syntax/rename_section.rb +78 -0
  108. data/lib/git/commands/config_option_syntax/replace_all.rb +104 -0
  109. data/lib/git/commands/config_option_syntax/set.rb +114 -0
  110. data/lib/git/commands/config_option_syntax/unset.rb +89 -0
  111. data/lib/git/commands/config_option_syntax/unset_all.rb +89 -0
  112. data/lib/git/commands/config_option_syntax.rb +56 -0
  113. data/lib/git/commands/describe.rb +155 -0
  114. data/lib/git/commands/diff.rb +656 -0
  115. data/lib/git/commands/diff_files.rb +518 -0
  116. data/lib/git/commands/diff_index.rb +496 -0
  117. data/lib/git/commands/fetch.rb +352 -0
  118. data/lib/git/commands/fsck.rb +136 -0
  119. data/lib/git/commands/gc.rb +132 -0
  120. data/lib/git/commands/grep.rb +338 -0
  121. data/lib/git/commands/init.rb +99 -0
  122. data/lib/git/commands/log.rb +632 -0
  123. data/lib/git/commands/ls_files.rb +191 -0
  124. data/lib/git/commands/ls_remote.rb +155 -0
  125. data/lib/git/commands/ls_tree.rb +131 -0
  126. data/lib/git/commands/maintenance/register.rb +75 -0
  127. data/lib/git/commands/maintenance/run.rb +104 -0
  128. data/lib/git/commands/maintenance/start.rb +66 -0
  129. data/lib/git/commands/maintenance/stop.rb +55 -0
  130. data/lib/git/commands/maintenance/unregister.rb +79 -0
  131. data/lib/git/commands/maintenance.rb +31 -0
  132. data/lib/git/commands/merge/abort.rb +44 -0
  133. data/lib/git/commands/merge/continue.rb +44 -0
  134. data/lib/git/commands/merge/quit.rb +46 -0
  135. data/lib/git/commands/merge/start.rb +245 -0
  136. data/lib/git/commands/merge.rb +28 -0
  137. data/lib/git/commands/merge_base.rb +86 -0
  138. data/lib/git/commands/mv.rb +77 -0
  139. data/lib/git/commands/name_rev.rb +114 -0
  140. data/lib/git/commands/pull.rb +377 -0
  141. data/lib/git/commands/push.rb +246 -0
  142. data/lib/git/commands/read_tree.rb +149 -0
  143. data/lib/git/commands/remote/add.rb +91 -0
  144. data/lib/git/commands/remote/get_url.rb +66 -0
  145. data/lib/git/commands/remote/list.rb +54 -0
  146. data/lib/git/commands/remote/prune.rb +61 -0
  147. data/lib/git/commands/remote/remove.rb +52 -0
  148. data/lib/git/commands/remote/rename.rb +69 -0
  149. data/lib/git/commands/remote/set_branches.rb +63 -0
  150. data/lib/git/commands/remote/set_head.rb +82 -0
  151. data/lib/git/commands/remote/set_url.rb +71 -0
  152. data/lib/git/commands/remote/set_url_add.rb +61 -0
  153. data/lib/git/commands/remote/set_url_delete.rb +64 -0
  154. data/lib/git/commands/remote/show.rb +71 -0
  155. data/lib/git/commands/remote/update.rb +72 -0
  156. data/lib/git/commands/remote.rb +42 -0
  157. data/lib/git/commands/repack.rb +277 -0
  158. data/lib/git/commands/reset.rb +147 -0
  159. data/lib/git/commands/rev_parse.rb +297 -0
  160. data/lib/git/commands/revert/abort.rb +45 -0
  161. data/lib/git/commands/revert/continue.rb +57 -0
  162. data/lib/git/commands/revert/quit.rb +47 -0
  163. data/lib/git/commands/revert/skip.rb +44 -0
  164. data/lib/git/commands/revert/start.rb +153 -0
  165. data/lib/git/commands/revert.rb +29 -0
  166. data/lib/git/commands/rm.rb +114 -0
  167. data/lib/git/commands/show.rb +632 -0
  168. data/lib/git/commands/show_ref/exclude_existing.rb +120 -0
  169. data/lib/git/commands/show_ref/exists.rb +78 -0
  170. data/lib/git/commands/show_ref/list.rb +145 -0
  171. data/lib/git/commands/show_ref/verify.rb +120 -0
  172. data/lib/git/commands/show_ref.rb +42 -0
  173. data/lib/git/commands/stash/apply.rb +75 -0
  174. data/lib/git/commands/stash/branch.rb +65 -0
  175. data/lib/git/commands/stash/clear.rb +41 -0
  176. data/lib/git/commands/stash/create.rb +58 -0
  177. data/lib/git/commands/stash/drop.rb +67 -0
  178. data/lib/git/commands/stash/list.rb +39 -0
  179. data/lib/git/commands/stash/pop.rb +78 -0
  180. data/lib/git/commands/stash/push.rb +103 -0
  181. data/lib/git/commands/stash/show.rb +149 -0
  182. data/lib/git/commands/stash/store.rb +63 -0
  183. data/lib/git/commands/stash.rb +38 -0
  184. data/lib/git/commands/status.rb +169 -0
  185. data/lib/git/commands/symbolic_ref/delete.rb +68 -0
  186. data/lib/git/commands/symbolic_ref/read.rb +95 -0
  187. data/lib/git/commands/symbolic_ref/update.rb +76 -0
  188. data/lib/git/commands/symbolic_ref.rb +38 -0
  189. data/lib/git/commands/tag/create.rb +139 -0
  190. data/lib/git/commands/tag/delete.rb +55 -0
  191. data/lib/git/commands/tag/list.rb +143 -0
  192. data/lib/git/commands/tag/verify.rb +71 -0
  193. data/lib/git/commands/tag.rb +26 -0
  194. data/lib/git/commands/update_ref/batch.rb +140 -0
  195. data/lib/git/commands/update_ref/delete.rb +92 -0
  196. data/lib/git/commands/update_ref/update.rb +106 -0
  197. data/lib/git/commands/update_ref.rb +42 -0
  198. data/lib/git/commands/version.rb +52 -0
  199. data/lib/git/commands/worktree/add.rb +140 -0
  200. data/lib/git/commands/worktree/list.rb +64 -0
  201. data/lib/git/commands/worktree/lock.rb +58 -0
  202. data/lib/git/commands/worktree/management_base.rb +51 -0
  203. data/lib/git/commands/worktree/move.rb +66 -0
  204. data/lib/git/commands/worktree/prune.rb +67 -0
  205. data/lib/git/commands/worktree/remove.rb +63 -0
  206. data/lib/git/commands/worktree/repair.rb +76 -0
  207. data/lib/git/commands/worktree/unlock.rb +47 -0
  208. data/lib/git/commands/worktree.rb +43 -0
  209. data/lib/git/commands/write_tree.rb +68 -0
  210. data/lib/git/commands.rb +89 -0
  211. data/lib/git/detached_head_info.rb +54 -0
  212. data/lib/git/diff.rb +297 -7
  213. data/lib/git/diff_file_numstat_info.rb +29 -0
  214. data/lib/git/diff_file_patch_info.rb +134 -0
  215. data/lib/git/diff_file_raw_info.rb +127 -0
  216. data/lib/git/diff_info.rb +169 -0
  217. data/lib/git/diff_path_status.rb +78 -19
  218. data/lib/git/diff_result.rb +32 -0
  219. data/lib/git/diff_stats.rb +59 -14
  220. data/lib/git/dirstat_info.rb +86 -0
  221. data/lib/git/errors.rb +65 -2
  222. data/lib/git/execution_context/global.rb +56 -0
  223. data/lib/git/execution_context/repository.rb +147 -0
  224. data/lib/git/execution_context.rb +482 -0
  225. data/lib/git/file_ref.rb +74 -0
  226. data/lib/git/fsck_object.rb +9 -9
  227. data/lib/git/fsck_result.rb +1 -1
  228. data/lib/git/lib.rb +1606 -1028
  229. data/lib/git/log.rb +15 -2
  230. data/lib/git/object.rb +92 -22
  231. data/lib/git/parsers/branch.rb +224 -0
  232. data/lib/git/parsers/cat_file.rb +111 -0
  233. data/lib/git/parsers/diff.rb +585 -0
  234. data/lib/git/parsers/fsck.rb +133 -0
  235. data/lib/git/parsers/grep.rb +42 -0
  236. data/lib/git/parsers/ls_tree.rb +58 -0
  237. data/lib/git/parsers/stash.rb +208 -0
  238. data/lib/git/parsers/tag.rb +257 -0
  239. data/lib/git/remote.rb +133 -9
  240. data/lib/git/repository/branching.rb +572 -0
  241. data/lib/git/repository/committing.rb +191 -0
  242. data/lib/git/repository/configuring.rb +156 -0
  243. data/lib/git/repository/diffing.rb +775 -0
  244. data/lib/git/repository/inspecting.rb +153 -0
  245. data/lib/git/repository/logging.rb +247 -0
  246. data/lib/git/repository/merging.rb +295 -0
  247. data/lib/git/repository/object_operations.rb +1101 -0
  248. data/lib/git/repository/path_resolver.rb +207 -0
  249. data/lib/git/repository/remote_operations.rb +753 -0
  250. data/lib/git/repository/shared_private.rb +51 -0
  251. data/lib/git/repository/staging.rb +390 -0
  252. data/lib/git/repository/stashing.rb +107 -0
  253. data/lib/git/repository/status_operations.rb +180 -0
  254. data/lib/git/repository/worktree_operations.rb +159 -0
  255. data/lib/git/repository.rb +264 -1
  256. data/lib/git/stash.rb +85 -4
  257. data/lib/git/stash_info.rb +104 -0
  258. data/lib/git/stashes.rb +130 -13
  259. data/lib/git/status.rb +224 -18
  260. data/lib/git/tag_delete_failure.rb +31 -0
  261. data/lib/git/tag_delete_result.rb +63 -0
  262. data/lib/git/tag_info.rb +105 -0
  263. data/lib/git/version.rb +109 -2
  264. data/lib/git/version_constraint.rb +81 -0
  265. data/lib/git/worktree.rb +120 -5
  266. data/lib/git/worktrees.rb +107 -7
  267. data/lib/git.rb +114 -18
  268. data/redesign/1_architecture_existing.md +54 -18
  269. data/redesign/2_architecture_redesign.md +365 -46
  270. data/redesign/3_architecture_implementation.md +1451 -54
  271. data/tasks/gem_tasks.rake +4 -0
  272. data/tasks/npm_tasks.rake +7 -0
  273. data/tasks/rspec.rake +48 -0
  274. data/tasks/test.rake +13 -1
  275. data/tasks/yard.rake +34 -7
  276. metadata +349 -20
  277. data/lib/git/index.rb +0 -6
  278. data/lib/git/path.rb +0 -38
  279. data/lib/git/working_directory.rb +0 -6
  280. /data/{release-please-config.json → .release-please-config.json} +0 -0
@@ -0,0 +1,352 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git fetch` command
8
+ #
9
+ # Downloads objects and refs from another repository. Fetches branches
10
+ # and/or tags from one or more other repositories, along with the objects
11
+ # necessary to complete their histories.
12
+ #
13
+ # @example Typical usage
14
+ # fetch = Git::Commands::Fetch.new(execution_context)
15
+ # fetch.call
16
+ # fetch.call('origin')
17
+ # fetch.call('origin', 'refs/heads/main')
18
+ # fetch.call(all: true, prune: true)
19
+ # fetch.call('origin', merge: true)
20
+ #
21
+ # @note `arguments` block audited against
22
+ # https://git-scm.com/docs/git-fetch/2.53.0
23
+ #
24
+ # @see https://git-scm.com/docs/git-fetch git-fetch
25
+ #
26
+ # @see Git::Commands
27
+ #
28
+ # @api private
29
+ #
30
+ class Fetch < Git::Commands::Base
31
+ arguments do
32
+ literal 'fetch'
33
+
34
+ # Remote scope
35
+ flag_option :all, negatable: true
36
+ flag_option %i[append a]
37
+ flag_option :atomic
38
+
39
+ # Shallow clone controls
40
+ value_option :depth, inline: true
41
+ value_option :deepen, inline: true
42
+ value_option :shallow_since, inline: true
43
+ value_option :shallow_exclude,
44
+ inline: true, repeatable: true
45
+ flag_option :unshallow
46
+ flag_option :update_shallow
47
+
48
+ # Negotiation
49
+ value_option :negotiation_tip, inline: true, repeatable: true
50
+ flag_option :negotiate_only
51
+
52
+ # Output and dry-run
53
+ flag_option :dry_run
54
+ flag_option :porcelain
55
+ flag_option :write_fetch_head, negatable: true
56
+
57
+ # Safety and update control
58
+ flag_option %i[force f]
59
+ flag_option %i[keep k]
60
+ flag_option :multiple
61
+
62
+ # Maintenance
63
+ flag_option :auto_maintenance, negatable: true
64
+ flag_option :auto_gc, negatable: true
65
+ flag_option :write_commit_graph, negatable: true
66
+
67
+ # Prefetching
68
+ flag_option :prefetch
69
+
70
+ # Pruning
71
+ flag_option %i[prune p]
72
+ flag_option %i[prune_tags P]
73
+
74
+ # Refetching and refmapping
75
+ flag_option :refetch
76
+ value_option :refmap, inline: true, repeatable: true
77
+
78
+ # Tag handling
79
+ flag_option %i[tags t], negatable: true
80
+
81
+ # Submodules
82
+ flag_or_value_option :recurse_submodules,
83
+ inline: true, negatable: true
84
+
85
+ # Parallelism
86
+ value_option %i[jobs j], inline: true
87
+
88
+ # Tracking and internal plumbing
89
+ flag_option :set_upstream
90
+ value_option :submodule_prefix, inline: true
91
+ value_option :recurse_submodules_default, inline: true
92
+ flag_option %i[update_head_ok u]
93
+ value_option :upload_pack
94
+
95
+ # Output verbosity
96
+ flag_option %i[quiet q]
97
+ flag_option %i[verbose v]
98
+ flag_option :progress
99
+
100
+ # Protocol and connectivity
101
+ value_option %i[server_option o],
102
+ inline: true, repeatable: true
103
+ flag_option :show_forced_updates, negatable: true
104
+ flag_option %i[ipv4 4]
105
+ flag_option %i[ipv6 6]
106
+
107
+ # Stdin
108
+ flag_option :stdin
109
+
110
+ # Execution-only options (not emitted as CLI flags)
111
+ execution_option :timeout
112
+ execution_option :merge
113
+
114
+ end_of_options
115
+ operand :repository
116
+ operand :refspec, repeatable: true
117
+ end
118
+
119
+ # @!method call(*, **)
120
+ #
121
+ # @overload call(repository = nil, *refspec, **options)
122
+ #
123
+ # Execute the `git fetch` command
124
+ #
125
+ # @param repository [String, nil] (nil) the remote name or URL to fetch from
126
+ #
127
+ # When nil, git uses the default remote configured for the current branch.
128
+ #
129
+ # @param refspec [Array<String>] one or more refspecs to fetch
130
+ #
131
+ # Each may be a branch name, a refspec pattern such as
132
+ # `+refs/heads/*:refs/remotes/origin/*`, or a commit SHA.
133
+ #
134
+ # @param options [Hash] command options
135
+ #
136
+ # @option options [Boolean, nil] :all (nil) fetch all remotes (`--all`)
137
+ #
138
+ # @option options [Boolean, nil] :no_all (nil) do not fetch all remotes (`--no-all`)
139
+ #
140
+ # @option options [Boolean, nil] :append (nil) append ref names and object
141
+ # names of fetched refs to the existing contents of `.git/FETCH_HEAD`
142
+ #
143
+ # Alias: :a
144
+ #
145
+ # @option options [Boolean, nil] :atomic (nil) use an atomic transaction
146
+ # to update local refs
147
+ #
148
+ # @option options [String] :depth (nil) limit fetching to the specified
149
+ # number of commits from the tip of each remote branch history
150
+ #
151
+ # @option options [String] :deepen (nil) deepen or shorten history by
152
+ # the specified number of commits from the current shallow boundary
153
+ #
154
+ # @option options [String] :shallow_since (nil) deepen or shorten the
155
+ # history to include all reachable commits after the given date
156
+ #
157
+ # @option options [String, Array<String>] :shallow_exclude (nil) exclude
158
+ # commits reachable from the specified remote branch or tag
159
+ #
160
+ # Repeatable.
161
+ #
162
+ # @option options [Boolean, nil] :unshallow (nil) convert a shallow
163
+ # repository to a complete one, or fetch as much as possible from
164
+ # a shallow source
165
+ #
166
+ # @option options [Boolean, nil] :update_shallow (nil) accept refs that
167
+ # would normally require updating `.git/shallow`
168
+ #
169
+ # @option options [String, Array<String>] :negotiation_tip (nil) only
170
+ # report commits reachable from the given tips when negotiating
171
+ #
172
+ # Repeatable. The argument may be a ref, a glob on ref names, or an
173
+ # abbreviated SHA-1.
174
+ #
175
+ # @option options [Boolean, nil] :negotiate_only (nil) do not fetch
176
+ # anything from the server; print ancestors of `--negotiation-tip`
177
+ # arguments that we have in common
178
+ #
179
+ # @option options [Boolean, nil] :dry_run (nil) show what would be done
180
+ # without making changes
181
+ #
182
+ # @option options [Boolean, nil] :porcelain (nil) print the output to
183
+ # standard output in an easy-to-parse format for scripts
184
+ #
185
+ # @option options [Boolean, nil] :write_fetch_head (nil) write the fetched
186
+ # remote refs to `.git/FETCH_HEAD` (`--write-fetch-head`)
187
+ #
188
+ # @option options [Boolean, nil] :no_write_fetch_head (nil) do not write
189
+ # fetched remote refs to `.git/FETCH_HEAD` (`--no-write-fetch-head`)
190
+ #
191
+ # @option options [Boolean, nil] :force (nil) override the fast-forward
192
+ # check when using explicit refspecs
193
+ #
194
+ # Alias: :f
195
+ #
196
+ # @option options [Boolean, nil] :keep (nil) keep the downloaded pack
197
+ #
198
+ # Alias: :k
199
+ #
200
+ # @option options [Boolean, nil] :multiple (nil) allow several repository
201
+ # and group arguments to be specified
202
+ #
203
+ # When using this option, pass additional repository or group names
204
+ # as extra positional arguments; they are bound to the `:refspec`
205
+ # slot in the DSL but are passed through to git correctly.
206
+ #
207
+ # @option options [Boolean, nil] :auto_maintenance (nil) run automatic
208
+ # repository maintenance after fetching (`--auto-maintenance`)
209
+ #
210
+ # @option options [Boolean, nil] :no_auto_maintenance (nil) do not run
211
+ # automatic repository maintenance after fetching
212
+ # (`--no-auto-maintenance`)
213
+ #
214
+ # @option options [Boolean, nil] :auto_gc (nil) run automatic garbage
215
+ # collection after fetching — deprecated alias for `:auto_maintenance`
216
+ # (`--auto-gc`)
217
+ #
218
+ # @option options [Boolean, nil] :no_auto_gc (nil) do not run automatic
219
+ # garbage collection after fetching (`--no-auto-gc`)
220
+ #
221
+ # @option options [Boolean, nil] :write_commit_graph (nil) write a
222
+ # commit-graph after fetching (`--write-commit-graph`)
223
+ #
224
+ # @option options [Boolean, nil] :no_write_commit_graph (nil) do not write
225
+ # a commit-graph after fetching (`--no-write-commit-graph`)
226
+ #
227
+ # @option options [Boolean, nil] :prefetch (nil) modify the configured
228
+ # refspec to place all refs into the `refs/prefetch/` namespace
229
+ #
230
+ # @option options [Boolean, nil] :prune (nil) before fetching, remove any
231
+ # remote-tracking references that no longer exist on the remote
232
+ #
233
+ # Alias: :p
234
+ #
235
+ # @option options [Boolean, nil] :prune_tags (nil) before fetching, remove
236
+ # any local tags that no longer exist on the remote (requires
237
+ # `--prune`)
238
+ #
239
+ # Alias: :P
240
+ #
241
+ # @option options [Boolean, nil] :refetch (nil) fetch all objects as a
242
+ # fresh clone would, bypassing negotiation
243
+ #
244
+ # @option options [String, Array<String>] :refmap (nil) use the
245
+ # specified refspec to map refs to remote-tracking branches instead
246
+ # of the configured `remote.*.fetch` values
247
+ #
248
+ # Repeatable.
249
+ #
250
+ # @option options [Boolean, nil] :tags (nil) fetch all tags from the
251
+ # remote (`--tags`)
252
+ #
253
+ # Alias: :t
254
+ #
255
+ # @option options [Boolean, nil] :no_tags (nil) disable automatic tag
256
+ # following (`--no-tags`)
257
+ #
258
+ # @option options [Boolean, String, nil] :recurse_submodules (nil) control
259
+ # whether new commits of submodules should be fetched
260
+ #
261
+ # When `true`, uses `--recurse-submodules`. When a string (e.g.
262
+ # `'yes'`, `'on-demand'`, `'no'`), passes that value.
263
+ #
264
+ # @option options [Boolean, nil] :no_recurse_submodules (nil) do not
265
+ # recurse into submodules (`--no-recurse-submodules`)
266
+ #
267
+ # @option options [String] :jobs (nil) number of submodules or parallel
268
+ # fetches
269
+ #
270
+ # Alias: :j
271
+ #
272
+ # @option options [Boolean, nil] :set_upstream (nil) add upstream tracking
273
+ # reference if the remote is fetched successfully
274
+ #
275
+ # @option options [String] :submodule_prefix (nil) prepend the given
276
+ # path to informative messages such as "Fetching submodule foo"
277
+ #
278
+ # Used internally when recursing over submodules.
279
+ #
280
+ # @option options [String] :recurse_submodules_default (nil) provide a
281
+ # non-negative default value for `--recurse-submodules`
282
+ #
283
+ # Used internally.
284
+ #
285
+ # @option options [Boolean, nil] :update_head_ok (nil) allow updating the
286
+ # HEAD that corresponds to the current branch
287
+ #
288
+ # Used internally by `git pull`.
289
+ #
290
+ # Alias: :u
291
+ #
292
+ # @option options [String] :upload_pack (nil) specify a non-default
293
+ # path for `git-upload-pack` on the remote side
294
+ #
295
+ # @option options [Boolean, nil] :quiet (nil) suppress all output
296
+ #
297
+ # Alias: :q
298
+ #
299
+ # @option options [Boolean, nil] :verbose (nil) be verbose
300
+ #
301
+ # Alias: :v
302
+ #
303
+ # @option options [Boolean, nil] :progress (nil) force progress status on
304
+ # standard error even when the stream is not attached to a terminal
305
+ #
306
+ # @option options [String, Array<String>] :server_option (nil) transmit
307
+ # the given string to the server when communicating using protocol
308
+ # version 2
309
+ #
310
+ # Repeatable.
311
+ #
312
+ # Alias: :o
313
+ #
314
+ # @option options [Boolean, nil] :show_forced_updates (nil) check for
315
+ # force-updated branches during fetch (`--show-forced-updates`)
316
+ #
317
+ # @option options [Boolean, nil] :no_show_forced_updates (nil) do not
318
+ # check for force-updated branches during fetch
319
+ # (`--no-show-forced-updates`)
320
+ #
321
+ # @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only
322
+ #
323
+ # Alias: :"4"
324
+ #
325
+ # @option options [Boolean, nil] :ipv6 (nil) use IPv6 addresses only
326
+ #
327
+ # Alias: :"6"
328
+ #
329
+ # @option options [Boolean, nil] :stdin (nil) read refspecs from stdin in
330
+ # addition to those provided as arguments
331
+ #
332
+ # @option options [Numeric, nil] :timeout (nil) maximum seconds to wait
333
+ # for the command to complete
334
+ #
335
+ # If nil, uses the global timeout from {Git::Config}.
336
+ #
337
+ # @option options [Boolean, nil] :merge (nil) merge stderr into stdout in
338
+ # the returned result
339
+ #
340
+ # Pass `true` to capture git fetch output (which is written to stderr
341
+ # by default).
342
+ #
343
+ # @return [Git::CommandLineResult] the result of calling `git fetch`
344
+ #
345
+ # @raise [ArgumentError] if unsupported options are provided
346
+ #
347
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
348
+ #
349
+ # @api public
350
+ end
351
+ end
352
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git fsck` command
8
+ #
9
+ # Verifies the connectivity and validity of objects in the database.
10
+ # It checks the integrity of the repository, reporting any dangling, missing, or
11
+ # unreachable objects.
12
+ #
13
+ # @example Typical usage
14
+ # fsck = Git::Commands::Fsck.new(execution_context)
15
+ # fsck.call
16
+ # fsck.call('abc1234', 'def5678')
17
+ # fsck.call(unreachable: true, strict: true)
18
+ # fsck.call(no_dangling: true)
19
+ #
20
+ # @note `arguments` block audited against https://git-scm.com/docs/git-fsck/2.53.0
21
+ #
22
+ # @see https://git-scm.com/docs/git-fsck git-fsck
23
+ #
24
+ # @see Git::Commands
25
+ #
26
+ # @api private
27
+ #
28
+ class Fsck < Git::Commands::Base
29
+ arguments do
30
+ literal 'fsck'
31
+ flag_option :progress, negatable: true
32
+
33
+ # Ref reporting
34
+ flag_option :tags
35
+ flag_option :root
36
+ flag_option :unreachable
37
+ flag_option :cache
38
+ flag_option :no_reflogs
39
+
40
+ # Checking scope
41
+ flag_option :full, negatable: true
42
+ flag_option :strict
43
+ flag_option :verbose
44
+ flag_option :lost_found
45
+
46
+ # Output control
47
+ flag_option :dangling, negatable: true
48
+ flag_option :connectivity_only
49
+ flag_option :name_objects, negatable: true
50
+ flag_option :references, negatable: true
51
+
52
+ operand :object, repeatable: true
53
+ end
54
+
55
+ # git fsck uses exit codes 0-7 as bit flags for findings
56
+ allow_exit_status 0..7
57
+
58
+ # @!method call(*, **)
59
+ #
60
+ # @overload call(*object, **options)
61
+ #
62
+ # Execute the `git fsck` command
63
+ #
64
+ # @param object [Array<String>] zero or more object identifiers to check
65
+ #
66
+ # When none are given, git fsck defaults to using the index file and
67
+ # all references as heads.
68
+ #
69
+ # @param options [Hash] command options
70
+ #
71
+ # @option options [Boolean, nil] :tags (nil) report tags
72
+ #
73
+ # @option options [Boolean, nil] :root (nil) report root nodes
74
+ #
75
+ # @option options [Boolean, nil] :unreachable (nil) print out objects that
76
+ # exist but are not reachable from any of the reference nodes
77
+ #
78
+ # @option options [Boolean, nil] :cache (nil) consider any object recorded
79
+ # in the index also as a head node for reachability
80
+ #
81
+ # @option options [Boolean, nil] :no_reflogs (nil) do not consider commits
82
+ # referenced only by reflogs to be reachable
83
+ #
84
+ # @option options [Boolean, nil] :full (nil) check not just objects in
85
+ # `GIT_OBJECT_DIRECTORY` but also those in alternate object pools and
86
+ # packed archives (`--full`)
87
+ #
88
+ # @option options [Boolean, nil] :no_full (nil) skip checking alternate object
89
+ # pools and packed archives (`--no-full`)
90
+ #
91
+ # @option options [Boolean, nil] :strict (nil) enable more strict checking,
92
+ # catching files with `g+w` bits set
93
+ #
94
+ # @option options [Boolean, nil] :verbose (nil) be chatty
95
+ #
96
+ # @option options [Boolean, nil] :lost_found (nil) write dangling objects
97
+ # into `.git/lost-found/commit/` or `.git/lost-found/other/`
98
+ #
99
+ # @option options [Boolean, nil] :dangling (nil) print dangling objects (`--dangling`)
100
+ #
101
+ # @option options [Boolean, nil] :no_dangling (nil) suppress dangling object
102
+ # reporting (`--no-dangling`)
103
+ #
104
+ # @option options [Boolean, nil] :progress (nil) show progress status on
105
+ # standard error (`--progress`)
106
+ #
107
+ # @option options [Boolean, nil] :no_progress (nil) suppress progress output
108
+ # when attached to a terminal (`--no-progress`)
109
+ #
110
+ # @option options [Boolean, nil] :connectivity_only (nil) check only the
111
+ # connectivity of reachable objects; faster but does not validate
112
+ # blob content
113
+ #
114
+ # @option options [Boolean, nil] :name_objects (nil) show the name of each
115
+ # reachable object alongside its identifier (`--name-objects`)
116
+ #
117
+ # @option options [Boolean, nil] :no_name_objects (nil) suppress object name
118
+ # display (`--no-name-objects`)
119
+ #
120
+ # @option options [Boolean, nil] :references (nil) check reference database
121
+ # consistency via `git refs verify` (`--references`)
122
+ #
123
+ # @option options [Boolean, nil] :no_references (nil) skip reference checking
124
+ # (`--no-references`)
125
+ #
126
+ # @return [Git::CommandLineResult] the result of calling `git fsck`
127
+ #
128
+ # @raise [ArgumentError] if unsupported options are provided
129
+ #
130
+ # @raise [Git::FailedError] if git exits outside the allowed range
131
+ # (exit code > 7)
132
+ #
133
+ # @api public
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git gc` command
8
+ #
9
+ # Runs a number of housekeeping tasks within the current repository, such as
10
+ # compressing file revisions (to reduce disk space and increase performance),
11
+ # removing unreachable objects, packing refs, pruning reflog, rerere metadata
12
+ # or stale working trees.
13
+ #
14
+ # @example Typical usage
15
+ # gc = Git::Commands::Gc.new(execution_context)
16
+ # gc.call
17
+ # gc.call(auto: true)
18
+ # gc.call(aggressive: true, prune: 'now')
19
+ #
20
+ # @note `arguments` block audited against
21
+ # https://git-scm.com/docs/git-gc/2.53.0
22
+ #
23
+ # @see https://git-scm.com/docs/git-gc git-gc
24
+ #
25
+ # @see Git::Commands
26
+ #
27
+ # @api private
28
+ #
29
+ class Gc < Git::Commands::Base
30
+ arguments do
31
+ literal 'gc'
32
+
33
+ # Optimization
34
+ flag_option :aggressive
35
+ flag_option :auto
36
+
37
+ # Background
38
+ flag_option :detach, negatable: true
39
+
40
+ # Cruft packs
41
+ flag_option :cruft, negatable: true
42
+ value_option :max_cruft_size, inline: true
43
+ value_option :expire_to, inline: true
44
+
45
+ # Pruning
46
+ flag_or_value_option :prune, negatable: true, inline: true
47
+
48
+ # Output control
49
+ flag_option :quiet
50
+
51
+ # Safety / override
52
+ flag_option :force
53
+ flag_option :keep_largest_pack
54
+ end
55
+
56
+ # @!method call(*, **)
57
+ #
58
+ # @overload call(**options)
59
+ #
60
+ # Execute the `git gc` command
61
+ #
62
+ # @param options [Hash] command options
63
+ #
64
+ # @option options [Boolean, nil] :aggressive (nil) be more thorough at the
65
+ # expense of increased runtime
66
+ #
67
+ # When `true`, git gc runs more aggressively to optimize the repository.
68
+ # The effects are mostly persistent.
69
+ #
70
+ # @option options [Boolean, nil] :auto (nil) check whether housekeeping is
71
+ # required before performing any work
72
+ #
73
+ # When `true`, git gc checks whether housekeeping is needed; if not, it
74
+ # exits without doing anything.
75
+ #
76
+ # @option options [Boolean, nil] :detach (nil) run in the background if the
77
+ # system supports it (`--detach`)
78
+ #
79
+ # Overrides the `gc.autoDetach` configuration.
80
+ #
81
+ # @option options [Boolean, nil] :no_detach (nil) run in the foreground
82
+ # (`--no-detach`)
83
+ #
84
+ # Overrides the `gc.autoDetach` configuration.
85
+ #
86
+ # @option options [Boolean, nil] :cruft (nil) pack unreachable objects into a
87
+ # cruft pack instead of storing them as loose objects (`--cruft`)
88
+ #
89
+ # @option options [Boolean, nil] :no_cruft (nil) do not create a cruft pack;
90
+ # store unreachable objects as loose objects (`--no-cruft`)
91
+ #
92
+ # @option options [String] :max_cruft_size (nil) limit the size of new
93
+ # cruft packs to at most `<n>` bytes when packing unreachable objects
94
+ #
95
+ # Overrides any value specified via `gc.maxCruftSize` configuration.
96
+ # Maps to `--max-cruft-size=<n>`.
97
+ #
98
+ # @option options [String] :expire_to (nil) write a cruft pack containing
99
+ # pruned objects (if any) to the given directory
100
+ #
101
+ # Only has an effect when used together with `:cruft`. Maps to
102
+ # `--expire-to=<dir>`.
103
+ #
104
+ # @option options [Boolean, String, nil] :prune (nil) prune loose objects
105
+ # older than the given date (`--prune`, `--prune=<date>`)
106
+ #
107
+ # When `true`, passes `--prune` (uses git's default expiry of 2 weeks
108
+ # ago). When a String, passes `--prune=<date>`.
109
+ #
110
+ # @option options [Boolean, nil] :no_prune (nil) do not prune any loose
111
+ # objects (`--no-prune`)
112
+ #
113
+ # @option options [Boolean, nil] :quiet (nil) suppress all progress reports
114
+ #
115
+ # @option options [Boolean, nil] :force (nil) force running gc even if
116
+ # another gc instance may be running on this repository
117
+ #
118
+ # @option options [Boolean, nil] :keep_largest_pack (nil) repack all packs
119
+ # except the largest non-cruft pack and those marked with a `.keep` file
120
+ #
121
+ # When `true`, `gc.bigPackThreshold` is ignored.
122
+ #
123
+ # @return [Git::CommandLineResult] the result of calling `git gc`
124
+ #
125
+ # @raise [ArgumentError] if unsupported options are provided
126
+ #
127
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
128
+ #
129
+ # @api public
130
+ end
131
+ end
132
+ end