git 1.19.1 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +5 -1
  3. data/AI_POLICY.md +24 -0
  4. data/CHANGELOG.md +689 -0
  5. data/CODE_OF_CONDUCT.md +25 -0
  6. data/CONTRIBUTING.md +1175 -97
  7. data/GOVERNANCE.md +106 -0
  8. data/LICENSE +1 -1
  9. data/MAINTAINERS.md +17 -4
  10. data/README.md +476 -320
  11. data/UPGRADING.md +1138 -0
  12. data/git.gemspec +124 -36
  13. data/lib/git/author.rb +39 -7
  14. data/lib/git/author_info.rb +66 -0
  15. data/lib/git/branch.rb +615 -65
  16. data/lib/git/branch_delete_failure.rb +34 -0
  17. data/lib/git/branch_delete_result.rb +66 -0
  18. data/lib/git/branch_info.rb +237 -0
  19. data/lib/git/branches.rb +167 -44
  20. data/lib/git/command_line/base.rb +247 -0
  21. data/lib/git/command_line/capturing.rb +308 -0
  22. data/lib/git/command_line/result.rb +88 -0
  23. data/lib/git/command_line/streaming.rb +236 -0
  24. data/lib/git/command_line.rb +52 -0
  25. data/lib/git/commands/add.rb +139 -0
  26. data/lib/git/commands/am/abort.rb +43 -0
  27. data/lib/git/commands/am/apply.rb +263 -0
  28. data/lib/git/commands/am/continue.rb +43 -0
  29. data/lib/git/commands/am/quit.rb +43 -0
  30. data/lib/git/commands/am/retry.rb +49 -0
  31. data/lib/git/commands/am/show_current_patch.rb +64 -0
  32. data/lib/git/commands/am/skip.rb +42 -0
  33. data/lib/git/commands/am.rb +33 -0
  34. data/lib/git/commands/apply.rb +242 -0
  35. data/lib/git/commands/archive/list_formats.rb +46 -0
  36. data/lib/git/commands/archive.rb +145 -0
  37. data/lib/git/commands/arguments.rb +4521 -0
  38. data/lib/git/commands/base.rb +502 -0
  39. data/lib/git/commands/branch/copy.rb +102 -0
  40. data/lib/git/commands/branch/create.rb +177 -0
  41. data/lib/git/commands/branch/delete.rb +88 -0
  42. data/lib/git/commands/branch/list.rb +178 -0
  43. data/lib/git/commands/branch/move.rb +102 -0
  44. data/lib/git/commands/branch/set_upstream.rb +86 -0
  45. data/lib/git/commands/branch/show_current.rb +49 -0
  46. data/lib/git/commands/branch/unset_upstream.rb +53 -0
  47. data/lib/git/commands/branch.rb +34 -0
  48. data/lib/git/commands/cat_file/batch.rb +385 -0
  49. data/lib/git/commands/cat_file/filtered.rb +105 -0
  50. data/lib/git/commands/cat_file/raw.rb +271 -0
  51. data/lib/git/commands/cat_file.rb +49 -0
  52. data/lib/git/commands/checkout/branch.rb +153 -0
  53. data/lib/git/commands/checkout/files.rb +116 -0
  54. data/lib/git/commands/checkout.rb +38 -0
  55. data/lib/git/commands/checkout_index.rb +106 -0
  56. data/lib/git/commands/clean.rb +102 -0
  57. data/lib/git/commands/clone.rb +241 -0
  58. data/lib/git/commands/commit.rb +273 -0
  59. data/lib/git/commands/commit_tree.rb +101 -0
  60. data/lib/git/commands/config_option_syntax/add.rb +86 -0
  61. data/lib/git/commands/config_option_syntax/get.rb +121 -0
  62. data/lib/git/commands/config_option_syntax/get_all.rb +118 -0
  63. data/lib/git/commands/config_option_syntax/get_color.rb +95 -0
  64. data/lib/git/commands/config_option_syntax/get_color_bool.rb +96 -0
  65. data/lib/git/commands/config_option_syntax/get_regexp.rb +119 -0
  66. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +111 -0
  67. data/lib/git/commands/config_option_syntax/list.rb +111 -0
  68. data/lib/git/commands/config_option_syntax/remove_section.rb +79 -0
  69. data/lib/git/commands/config_option_syntax/rename_section.rb +83 -0
  70. data/lib/git/commands/config_option_syntax/replace_all.rb +109 -0
  71. data/lib/git/commands/config_option_syntax/set.rb +119 -0
  72. data/lib/git/commands/config_option_syntax/unset.rb +92 -0
  73. data/lib/git/commands/config_option_syntax/unset_all.rb +94 -0
  74. data/lib/git/commands/config_option_syntax.rb +56 -0
  75. data/lib/git/commands/describe.rb +156 -0
  76. data/lib/git/commands/diff.rb +657 -0
  77. data/lib/git/commands/diff_files.rb +519 -0
  78. data/lib/git/commands/diff_index.rb +499 -0
  79. data/lib/git/commands/fetch.rb +354 -0
  80. data/lib/git/commands/fsck.rb +138 -0
  81. data/lib/git/commands/gc.rb +134 -0
  82. data/lib/git/commands/grep.rb +339 -0
  83. data/lib/git/commands/init.rb +101 -0
  84. data/lib/git/commands/log.rb +634 -0
  85. data/lib/git/commands/ls_files.rb +195 -0
  86. data/lib/git/commands/ls_remote.rb +161 -0
  87. data/lib/git/commands/ls_tree.rb +135 -0
  88. data/lib/git/commands/maintenance/register.rb +77 -0
  89. data/lib/git/commands/maintenance/run.rb +109 -0
  90. data/lib/git/commands/maintenance/start.rb +71 -0
  91. data/lib/git/commands/maintenance/stop.rb +60 -0
  92. data/lib/git/commands/maintenance/unregister.rb +84 -0
  93. data/lib/git/commands/maintenance.rb +31 -0
  94. data/lib/git/commands/merge/abort.rb +44 -0
  95. data/lib/git/commands/merge/continue.rb +44 -0
  96. data/lib/git/commands/merge/quit.rb +46 -0
  97. data/lib/git/commands/merge/start.rb +250 -0
  98. data/lib/git/commands/merge.rb +28 -0
  99. data/lib/git/commands/merge_base.rb +91 -0
  100. data/lib/git/commands/mv.rb +82 -0
  101. data/lib/git/commands/name_rev.rb +119 -0
  102. data/lib/git/commands/pull.rb +382 -0
  103. data/lib/git/commands/push.rb +251 -0
  104. data/lib/git/commands/read_tree.rb +154 -0
  105. data/lib/git/commands/remote/add.rb +96 -0
  106. data/lib/git/commands/remote/get_url.rb +68 -0
  107. data/lib/git/commands/remote/list.rb +56 -0
  108. data/lib/git/commands/remote/prune.rb +63 -0
  109. data/lib/git/commands/remote/remove.rb +52 -0
  110. data/lib/git/commands/remote/rename.rb +76 -0
  111. data/lib/git/commands/remote/set_branches.rb +70 -0
  112. data/lib/git/commands/remote/set_head.rb +89 -0
  113. data/lib/git/commands/remote/set_url.rb +78 -0
  114. data/lib/git/commands/remote/set_url_add.rb +70 -0
  115. data/lib/git/commands/remote/set_url_delete.rb +71 -0
  116. data/lib/git/commands/remote/show.rb +77 -0
  117. data/lib/git/commands/remote/update.rb +79 -0
  118. data/lib/git/commands/remote.rb +42 -0
  119. data/lib/git/commands/repack.rb +281 -0
  120. data/lib/git/commands/reset.rb +154 -0
  121. data/lib/git/commands/rev_parse.rb +304 -0
  122. data/lib/git/commands/revert/abort.rb +45 -0
  123. data/lib/git/commands/revert/continue.rb +62 -0
  124. data/lib/git/commands/revert/quit.rb +47 -0
  125. data/lib/git/commands/revert/skip.rb +44 -0
  126. data/lib/git/commands/revert/start.rb +158 -0
  127. data/lib/git/commands/revert.rb +29 -0
  128. data/lib/git/commands/rm.rb +113 -0
  129. data/lib/git/commands/show.rb +632 -0
  130. data/lib/git/commands/show_ref/exclude_existing.rb +119 -0
  131. data/lib/git/commands/show_ref/exists.rb +80 -0
  132. data/lib/git/commands/show_ref/list.rb +149 -0
  133. data/lib/git/commands/show_ref/verify.rb +122 -0
  134. data/lib/git/commands/show_ref.rb +42 -0
  135. data/lib/git/commands/stash/apply.rb +81 -0
  136. data/lib/git/commands/stash/branch.rb +67 -0
  137. data/lib/git/commands/stash/clear.rb +43 -0
  138. data/lib/git/commands/stash/create.rb +60 -0
  139. data/lib/git/commands/stash/drop.rb +73 -0
  140. data/lib/git/commands/stash/list.rb +43 -0
  141. data/lib/git/commands/stash/pop.rb +87 -0
  142. data/lib/git/commands/stash/push.rb +112 -0
  143. data/lib/git/commands/stash/show.rb +158 -0
  144. data/lib/git/commands/stash/store.rb +72 -0
  145. data/lib/git/commands/stash.rb +38 -0
  146. data/lib/git/commands/status.rb +174 -0
  147. data/lib/git/commands/symbolic_ref/delete.rb +72 -0
  148. data/lib/git/commands/symbolic_ref/read.rb +99 -0
  149. data/lib/git/commands/symbolic_ref/update.rb +79 -0
  150. data/lib/git/commands/symbolic_ref.rb +38 -0
  151. data/lib/git/commands/tag/create.rb +142 -0
  152. data/lib/git/commands/tag/delete.rb +57 -0
  153. data/lib/git/commands/tag/list.rb +146 -0
  154. data/lib/git/commands/tag/verify.rb +71 -0
  155. data/lib/git/commands/tag.rb +26 -0
  156. data/lib/git/commands/update_ref/batch.rb +145 -0
  157. data/lib/git/commands/update_ref/delete.rb +90 -0
  158. data/lib/git/commands/update_ref/update.rb +103 -0
  159. data/lib/git/commands/update_ref.rb +42 -0
  160. data/lib/git/commands/version.rb +60 -0
  161. data/lib/git/commands/worktree/add.rb +139 -0
  162. data/lib/git/commands/worktree/list.rb +64 -0
  163. data/lib/git/commands/worktree/lock.rb +58 -0
  164. data/lib/git/commands/worktree/management_base.rb +51 -0
  165. data/lib/git/commands/worktree/move.rb +66 -0
  166. data/lib/git/commands/worktree/prune.rb +67 -0
  167. data/lib/git/commands/worktree/remove.rb +63 -0
  168. data/lib/git/commands/worktree/repair.rb +76 -0
  169. data/lib/git/commands/worktree/unlock.rb +47 -0
  170. data/lib/git/commands/worktree.rb +43 -0
  171. data/lib/git/commands/write_tree.rb +68 -0
  172. data/lib/git/commands.rb +88 -0
  173. data/lib/git/config.rb +72 -5
  174. data/lib/git/config_entry_info.rb +106 -0
  175. data/lib/git/configuring.rb +795 -0
  176. data/lib/git/detached_head_info.rb +57 -0
  177. data/lib/git/diff.rb +437 -86
  178. data/lib/git/diff_file_numstat_info.rb +31 -0
  179. data/lib/git/diff_file_patch_info.rb +136 -0
  180. data/lib/git/diff_file_raw_info.rb +129 -0
  181. data/lib/git/diff_info.rb +162 -0
  182. data/lib/git/diff_path_status.rb +107 -0
  183. data/lib/git/diff_result.rb +34 -0
  184. data/lib/git/diff_stats.rb +111 -0
  185. data/lib/git/dirstat_info.rb +102 -0
  186. data/lib/git/encoding_utils.rb +32 -1
  187. data/lib/git/errors.rb +285 -0
  188. data/lib/git/escaped_path.rb +57 -5
  189. data/lib/git/execution_context/global.rb +31 -0
  190. data/lib/git/execution_context/repository.rb +151 -0
  191. data/lib/git/execution_context.rb +559 -0
  192. data/lib/git/factories.rb +813 -0
  193. data/lib/git/file_ref.rb +77 -0
  194. data/lib/git/fsck_object.rb +56 -0
  195. data/lib/git/fsck_result.rb +132 -0
  196. data/lib/git/log.rb +306 -90
  197. data/lib/git/object.rb +563 -141
  198. data/lib/git/parsers/branch.rb +240 -0
  199. data/lib/git/parsers/cat_file.rb +111 -0
  200. data/lib/git/parsers/config_entry.rb +110 -0
  201. data/lib/git/parsers/diff.rb +792 -0
  202. data/lib/git/parsers/fsck.rb +144 -0
  203. data/lib/git/parsers/grep.rb +42 -0
  204. data/lib/git/parsers/ls_remote.rb +79 -0
  205. data/lib/git/parsers/ls_tree.rb +58 -0
  206. data/lib/git/parsers/remote.rb +162 -0
  207. data/lib/git/parsers/stash.rb +292 -0
  208. data/lib/git/parsers/status.rb +251 -0
  209. data/lib/git/parsers/tag.rb +341 -0
  210. data/lib/git/parsers/worktree.rb +185 -0
  211. data/lib/git/path_resolver.rb +206 -0
  212. data/lib/git/remote.rb +165 -12
  213. data/lib/git/remote_info.rb +203 -0
  214. data/lib/git/repository/branching.rb +964 -0
  215. data/lib/git/repository/committing.rb +246 -0
  216. data/lib/git/repository/context_helpers.rb +293 -0
  217. data/lib/git/repository/diffing.rb +785 -0
  218. data/lib/git/repository/inspecting.rb +252 -0
  219. data/lib/git/repository/logging.rb +410 -0
  220. data/lib/git/repository/maintenance.rb +65 -0
  221. data/lib/git/repository/merging.rb +451 -0
  222. data/lib/git/repository/object_operations.rb +1551 -0
  223. data/lib/git/repository/remote_operations.rb +984 -0
  224. data/lib/git/repository/shared_private.rb +120 -0
  225. data/lib/git/repository/staging.rb +587 -0
  226. data/lib/git/repository/stashing.rb +623 -0
  227. data/lib/git/repository/status_operations.rb +249 -0
  228. data/lib/git/repository/worktree_operations.rb +339 -0
  229. data/lib/git/repository.rb +484 -2
  230. data/lib/git/stash.rb +109 -12
  231. data/lib/git/stash_info.rb +102 -0
  232. data/lib/git/stashes.rb +169 -26
  233. data/lib/git/status.rb +308 -122
  234. data/lib/git/status_file_info.rb +258 -0
  235. data/lib/git/status_info.rb +189 -0
  236. data/lib/git/tag_delete_failure.rb +34 -0
  237. data/lib/git/tag_delete_result.rb +66 -0
  238. data/lib/git/tag_info.rb +99 -0
  239. data/lib/git/url.rb +15 -8
  240. data/lib/git/version.rb +113 -2
  241. data/lib/git/version_constraint.rb +85 -0
  242. data/lib/git/worktree.rb +150 -8
  243. data/lib/git/worktree_info.rb +128 -0
  244. data/lib/git/worktrees.rb +118 -13
  245. data/lib/git.rb +632 -234
  246. metadata +369 -54
  247. data/.github/stale.yml +0 -25
  248. data/.github/workflows/continuous_integration.yml +0 -49
  249. data/.gitignore +0 -10
  250. data/Dockerfile.changelog-rs +0 -12
  251. data/Gemfile +0 -5
  252. data/ISSUE_TEMPLATE.md +0 -15
  253. data/PULL_REQUEST_TEMPLATE.md +0 -9
  254. data/RELEASING.md +0 -70
  255. data/Rakefile +0 -60
  256. data/lib/git/base/factory.rb +0 -99
  257. data/lib/git/base.rb +0 -711
  258. data/lib/git/command_line_result.rb +0 -86
  259. data/lib/git/failed_error.rb +0 -53
  260. data/lib/git/git_execute_error.rb +0 -7
  261. data/lib/git/index.rb +0 -5
  262. data/lib/git/lib.rb +0 -1328
  263. data/lib/git/path.rb +0 -31
  264. data/lib/git/signaled_error.rb +0 -50
  265. data/lib/git/working_directory.rb +0 -4
@@ -0,0 +1,354 @@
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
+ # @overload call(repository = nil, *refspec, **options)
120
+ #
121
+ # Execute the `git fetch` command
122
+ #
123
+ # @param repository [String, nil] (nil) the remote name or URL to fetch from
124
+ #
125
+ # When nil, git uses the default remote configured for the current branch.
126
+ #
127
+ # @param refspec [Array<String>] one or more refspecs to fetch
128
+ #
129
+ # Each may be a branch name, a refspec pattern such as
130
+ # `+refs/heads/*:refs/remotes/origin/*`, or a commit SHA.
131
+ #
132
+ # @param options [Hash] command options
133
+ #
134
+ # @option options [Boolean, nil] :all (nil) fetch all remotes (`--all`)
135
+ #
136
+ # @option options [Boolean, nil] :no_all (nil) do not fetch all remotes (`--no-all`)
137
+ #
138
+ # @option options [Boolean, nil] :append (nil) append ref names and object
139
+ # names of fetched refs to the existing contents of `.git/FETCH_HEAD`
140
+ #
141
+ # Alias: :a
142
+ #
143
+ # @option options [Boolean, nil] :atomic (nil) use an atomic transaction
144
+ # to update local refs
145
+ #
146
+ # @option options [String] :depth (nil) limit fetching to the specified
147
+ # number of commits from the tip of each remote branch history
148
+ #
149
+ # @option options [String] :deepen (nil) deepen or shorten history by
150
+ # the specified number of commits from the current shallow boundary
151
+ #
152
+ # @option options [String] :shallow_since (nil) deepen or shorten the
153
+ # history to include all reachable commits after the given date
154
+ #
155
+ # @option options [String, Array<String>] :shallow_exclude (nil) exclude
156
+ # commits reachable from the specified remote branch or tag
157
+ #
158
+ # Repeatable.
159
+ #
160
+ # @option options [Boolean, nil] :unshallow (nil) convert a shallow
161
+ # repository to a complete one, or fetch as much as possible from
162
+ # a shallow source
163
+ #
164
+ # @option options [Boolean, nil] :update_shallow (nil) accept refs that
165
+ # would normally require updating `.git/shallow`
166
+ #
167
+ # @option options [String, Array<String>] :negotiation_tip (nil) only
168
+ # report commits reachable from the given tips when negotiating
169
+ #
170
+ # Repeatable. The argument may be a ref, a glob on ref names, or an
171
+ # abbreviated SHA-1.
172
+ #
173
+ # @option options [Boolean, nil] :negotiate_only (nil) do not fetch
174
+ # anything from the server; print ancestors of `--negotiation-tip`
175
+ # arguments that we have in common
176
+ #
177
+ # @option options [Boolean, nil] :dry_run (nil) show what would be done
178
+ # without making changes
179
+ #
180
+ # @option options [Boolean, nil] :porcelain (nil) print the output to
181
+ # standard output in an easy-to-parse format for scripts
182
+ #
183
+ # @option options [Boolean, nil] :write_fetch_head (nil) write the fetched
184
+ # remote refs to `.git/FETCH_HEAD` (`--write-fetch-head`)
185
+ #
186
+ # @option options [Boolean, nil] :no_write_fetch_head (nil) do not write
187
+ # fetched remote refs to `.git/FETCH_HEAD` (`--no-write-fetch-head`)
188
+ #
189
+ # @option options [Boolean, nil] :force (nil) override the fast-forward
190
+ # check when using explicit refspecs
191
+ #
192
+ # Alias: :f
193
+ #
194
+ # @option options [Boolean, nil] :keep (nil) keep the downloaded pack
195
+ #
196
+ # Alias: :k
197
+ #
198
+ # @option options [Boolean, nil] :multiple (nil) allow several repository
199
+ # and group arguments to be specified
200
+ #
201
+ # When using this option, pass additional repository or group names
202
+ # as extra positional arguments; they are bound to the `:refspec`
203
+ # slot in the DSL but are passed through to git correctly.
204
+ #
205
+ # @option options [Boolean, nil] :auto_maintenance (nil) run automatic
206
+ # repository maintenance after fetching (`--auto-maintenance`)
207
+ #
208
+ # @option options [Boolean, nil] :no_auto_maintenance (nil) do not run
209
+ # automatic repository maintenance after fetching
210
+ # (`--no-auto-maintenance`)
211
+ #
212
+ # @option options [Boolean, nil] :auto_gc (nil) run automatic garbage
213
+ # collection after fetching — deprecated alias for `:auto_maintenance`
214
+ # (`--auto-gc`)
215
+ #
216
+ # @option options [Boolean, nil] :no_auto_gc (nil) do not run automatic
217
+ # garbage collection after fetching (`--no-auto-gc`)
218
+ #
219
+ # @option options [Boolean, nil] :write_commit_graph (nil) write a
220
+ # commit-graph after fetching (`--write-commit-graph`)
221
+ #
222
+ # @option options [Boolean, nil] :no_write_commit_graph (nil) do not write
223
+ # a commit-graph after fetching (`--no-write-commit-graph`)
224
+ #
225
+ # @option options [Boolean, nil] :prefetch (nil) modify the configured
226
+ # refspec to place all refs into the `refs/prefetch/` namespace
227
+ #
228
+ # @option options [Boolean, nil] :prune (nil) before fetching, remove any
229
+ # remote-tracking references that no longer exist on the remote
230
+ #
231
+ # Alias: :p
232
+ #
233
+ # @option options [Boolean, nil] :prune_tags (nil) before fetching, remove
234
+ # any local tags that no longer exist on the remote (requires
235
+ # `--prune`)
236
+ #
237
+ # Alias: :P
238
+ #
239
+ # @option options [Boolean, nil] :refetch (nil) fetch all objects as a
240
+ # fresh clone would, bypassing negotiation
241
+ #
242
+ # @option options [String, Array<String>] :refmap (nil) use the
243
+ # specified refspec to map refs to remote-tracking branches instead
244
+ # of the configured `remote.*.fetch` values
245
+ #
246
+ # Repeatable.
247
+ #
248
+ # @option options [Boolean, nil] :tags (nil) fetch all tags from the
249
+ # remote (`--tags`)
250
+ #
251
+ # Alias: :t
252
+ #
253
+ # @option options [Boolean, nil] :no_tags (nil) disable automatic tag
254
+ # following (`--no-tags`)
255
+ #
256
+ # @option options [Boolean, String, nil] :recurse_submodules (nil) control
257
+ # whether new commits of submodules should be fetched
258
+ #
259
+ # When `true`, uses `--recurse-submodules`. When a string (e.g.
260
+ # `'yes'`, `'on-demand'`, `'no'`), passes that value.
261
+ #
262
+ # @option options [Boolean, nil] :no_recurse_submodules (nil) do not
263
+ # recurse into submodules (`--no-recurse-submodules`)
264
+ #
265
+ # @option options [String] :jobs (nil) number of submodules or parallel
266
+ # fetches
267
+ #
268
+ # Alias: :j
269
+ #
270
+ # @option options [Boolean, nil] :set_upstream (nil) add upstream tracking
271
+ # reference if the remote is fetched successfully
272
+ #
273
+ # @option options [String] :submodule_prefix (nil) prepend the given
274
+ # path to informative messages such as "Fetching submodule foo"
275
+ #
276
+ # Used internally when recursing over submodules.
277
+ #
278
+ # @option options [String] :recurse_submodules_default (nil) provide a
279
+ # non-negative default value for `--recurse-submodules`
280
+ #
281
+ # Used internally.
282
+ #
283
+ # @option options [Boolean, nil] :update_head_ok (nil) allow updating the
284
+ # HEAD that corresponds to the current branch
285
+ #
286
+ # Used internally by `git pull`.
287
+ #
288
+ # Alias: :u
289
+ #
290
+ # @option options [String] :upload_pack (nil) specify a non-default
291
+ # path for `git-upload-pack` on the remote side
292
+ #
293
+ # @option options [Boolean, nil] :quiet (nil) suppress all output
294
+ #
295
+ # Alias: :q
296
+ #
297
+ # @option options [Boolean, nil] :verbose (nil) be verbose
298
+ #
299
+ # Alias: :v
300
+ #
301
+ # @option options [Boolean, nil] :progress (nil) force progress status on
302
+ # standard error even when the stream is not attached to a terminal
303
+ #
304
+ # @option options [String, Array<String>] :server_option (nil) transmit
305
+ # the given string to the server when communicating using protocol
306
+ # version 2
307
+ #
308
+ # Repeatable.
309
+ #
310
+ # Alias: :o
311
+ #
312
+ # @option options [Boolean, nil] :show_forced_updates (nil) check for
313
+ # force-updated branches during fetch (`--show-forced-updates`)
314
+ #
315
+ # @option options [Boolean, nil] :no_show_forced_updates (nil) do not
316
+ # check for force-updated branches during fetch
317
+ # (`--no-show-forced-updates`)
318
+ #
319
+ # @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only
320
+ #
321
+ # Alias: :"4"
322
+ #
323
+ # @option options [Boolean, nil] :ipv6 (nil) use IPv6 addresses only
324
+ #
325
+ # Alias: :"6"
326
+ #
327
+ # @option options [Boolean, nil] :stdin (nil) read refspecs from stdin in
328
+ # addition to those provided as arguments
329
+ #
330
+ # @option options [Numeric, nil] :timeout (nil) maximum seconds to wait
331
+ # for the command to complete
332
+ #
333
+ # If nil, uses the global timeout from {Git::Config}.
334
+ #
335
+ # @option options [Boolean, nil] :merge (nil) merge stderr into stdout in
336
+ # the returned result
337
+ #
338
+ # Pass `true` to capture git fetch output (which is written to stderr
339
+ # by default).
340
+ #
341
+ # @return [Git::CommandLine::Result] the result of calling `git fetch`
342
+ #
343
+ # @raise [ArgumentError] if unsupported options are provided
344
+ #
345
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
346
+ #
347
+ # @api public
348
+ #
349
+ def call(*, **)
350
+ super
351
+ end
352
+ end
353
+ end
354
+ end
@@ -0,0 +1,138 @@
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
+ # @overload call(*object, **options)
59
+ #
60
+ # Execute the `git fsck` command
61
+ #
62
+ # @param object [Array<String>] zero or more object identifiers to check
63
+ #
64
+ # When none are given, git fsck defaults to using the index file and
65
+ # all references as heads.
66
+ #
67
+ # @param options [Hash] command options
68
+ #
69
+ # @option options [Boolean, nil] :tags (nil) report tags
70
+ #
71
+ # @option options [Boolean, nil] :root (nil) report root nodes
72
+ #
73
+ # @option options [Boolean, nil] :unreachable (nil) print out objects that
74
+ # exist but are not reachable from any of the reference nodes
75
+ #
76
+ # @option options [Boolean, nil] :cache (nil) consider any object recorded
77
+ # in the index also as a head node for reachability
78
+ #
79
+ # @option options [Boolean, nil] :no_reflogs (nil) do not consider commits
80
+ # referenced only by reflogs to be reachable
81
+ #
82
+ # @option options [Boolean, nil] :full (nil) check not just objects in
83
+ # `GIT_OBJECT_DIRECTORY` but also those in alternate object pools and
84
+ # packed archives (`--full`)
85
+ #
86
+ # @option options [Boolean, nil] :no_full (nil) skip checking alternate object
87
+ # pools and packed archives (`--no-full`)
88
+ #
89
+ # @option options [Boolean, nil] :strict (nil) enable more strict checking,
90
+ # catching files with `g+w` bits set
91
+ #
92
+ # @option options [Boolean, nil] :verbose (nil) be chatty
93
+ #
94
+ # @option options [Boolean, nil] :lost_found (nil) write dangling objects
95
+ # into `.git/lost-found/commit/` or `.git/lost-found/other/`
96
+ #
97
+ # @option options [Boolean, nil] :dangling (nil) print dangling objects (`--dangling`)
98
+ #
99
+ # @option options [Boolean, nil] :no_dangling (nil) suppress dangling object
100
+ # reporting (`--no-dangling`)
101
+ #
102
+ # @option options [Boolean, nil] :progress (nil) show progress status on
103
+ # standard error (`--progress`)
104
+ #
105
+ # @option options [Boolean, nil] :no_progress (nil) suppress progress output
106
+ # when attached to a terminal (`--no-progress`)
107
+ #
108
+ # @option options [Boolean, nil] :connectivity_only (nil) check only the
109
+ # connectivity of reachable objects; faster but does not validate
110
+ # blob content
111
+ #
112
+ # @option options [Boolean, nil] :name_objects (nil) show the name of each
113
+ # reachable object alongside its identifier (`--name-objects`)
114
+ #
115
+ # @option options [Boolean, nil] :no_name_objects (nil) suppress object name
116
+ # display (`--no-name-objects`)
117
+ #
118
+ # @option options [Boolean, nil] :references (nil) check reference database
119
+ # consistency via `git refs verify` (`--references`)
120
+ #
121
+ # @option options [Boolean, nil] :no_references (nil) skip reference checking
122
+ # (`--no-references`)
123
+ #
124
+ # @return [Git::CommandLine::Result] the result of calling `git fsck`
125
+ #
126
+ # @raise [ArgumentError] if unsupported options are provided
127
+ #
128
+ # @raise [Git::FailedError] if git exits outside the allowed range
129
+ # (exit code > 7)
130
+ #
131
+ # @api public
132
+ #
133
+ def call(*, **)
134
+ super
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,134 @@
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
+ # @overload call(**options)
57
+ #
58
+ # Execute the `git gc` command
59
+ #
60
+ # @param options [Hash] command options
61
+ #
62
+ # @option options [Boolean, nil] :aggressive (nil) be more thorough at the
63
+ # expense of increased runtime
64
+ #
65
+ # When `true`, git gc runs more aggressively to optimize the repository.
66
+ # The effects are mostly persistent.
67
+ #
68
+ # @option options [Boolean, nil] :auto (nil) check whether housekeeping is
69
+ # required before performing any work
70
+ #
71
+ # When `true`, git gc checks whether housekeeping is needed; if not, it
72
+ # exits without doing anything.
73
+ #
74
+ # @option options [Boolean, nil] :detach (nil) run in the background if the
75
+ # system supports it (`--detach`)
76
+ #
77
+ # Overrides the `gc.autoDetach` configuration.
78
+ #
79
+ # @option options [Boolean, nil] :no_detach (nil) run in the foreground
80
+ # (`--no-detach`)
81
+ #
82
+ # Overrides the `gc.autoDetach` configuration.
83
+ #
84
+ # @option options [Boolean, nil] :cruft (nil) pack unreachable objects into a
85
+ # cruft pack instead of storing them as loose objects (`--cruft`)
86
+ #
87
+ # @option options [Boolean, nil] :no_cruft (nil) do not create a cruft pack;
88
+ # store unreachable objects as loose objects (`--no-cruft`)
89
+ #
90
+ # @option options [String] :max_cruft_size (nil) limit the size of new
91
+ # cruft packs to at most `<n>` bytes when packing unreachable objects
92
+ #
93
+ # Overrides any value specified via `gc.maxCruftSize` configuration.
94
+ # Maps to `--max-cruft-size=<n>`.
95
+ #
96
+ # @option options [String] :expire_to (nil) write a cruft pack containing
97
+ # pruned objects (if any) to the given directory
98
+ #
99
+ # Only has an effect when used together with `:cruft`. Maps to
100
+ # `--expire-to=<dir>`.
101
+ #
102
+ # @option options [Boolean, String, nil] :prune (nil) prune loose objects
103
+ # older than the given date (`--prune`, `--prune=<date>`)
104
+ #
105
+ # When `true`, passes `--prune` (uses git's default expiry of 2 weeks
106
+ # ago). When a String, passes `--prune=<date>`.
107
+ #
108
+ # @option options [Boolean, nil] :no_prune (nil) do not prune any loose
109
+ # objects (`--no-prune`)
110
+ #
111
+ # @option options [Boolean, nil] :quiet (nil) suppress all progress reports
112
+ #
113
+ # @option options [Boolean, nil] :force (nil) force running gc even if
114
+ # another gc instance may be running on this repository
115
+ #
116
+ # @option options [Boolean, nil] :keep_largest_pack (nil) repack all packs
117
+ # except the largest non-cruft pack and those marked with a `.keep` file
118
+ #
119
+ # When `true`, `gc.bigPackThreshold` is ignored.
120
+ #
121
+ # @return [Git::CommandLine::Result] the result of calling `git gc`
122
+ #
123
+ # @raise [ArgumentError] if unsupported options are provided
124
+ #
125
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
126
+ #
127
+ # @api public
128
+ #
129
+ def call(*, **)
130
+ super
131
+ end
132
+ end
133
+ end
134
+ end