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,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git merge-base` command to find common ancestors
8
+ #
9
+ # Finds as good common ancestors as possible for use in a three-way merge.
10
+ # Given two or more commits, it outputs a common ancestor reachable from
11
+ # all of them through the parent relationship.
12
+ #
13
+ # @example Find merge bases of two branches
14
+ # merge_base = Git::Commands::MergeBase.new(execution_context)
15
+ # merge_base.call('main', 'feature')
16
+ # merge_base.call('main', 'feature', all: true)
17
+ # merge_base.call('main', 'b1', 'b2', octopus: true)
18
+ # merge_base.call('main', 'feature', fork_point: true)
19
+ #
20
+ # @note `arguments` block audited against
21
+ # https://git-scm.com/docs/git-merge-base/2.53.0
22
+ #
23
+ # @see https://git-scm.com/docs/git-merge-base git-merge-base
24
+ #
25
+ # @api private
26
+ #
27
+ class MergeBase < Git::Commands::Base
28
+ arguments do
29
+ literal 'merge-base'
30
+
31
+ # Operation modes
32
+ flag_option :octopus
33
+ flag_option :independent
34
+ flag_option :is_ancestor
35
+ flag_option :fork_point
36
+
37
+ # Options
38
+ flag_option %i[all a]
39
+
40
+ end_of_options
41
+ operand :commit, repeatable: true, required: true
42
+ end
43
+
44
+ # git merge-base --fork-point returns exit code 1 when no fork point is
45
+ # found; --is-ancestor returns exit code 1 when the first commit is not an
46
+ # ancestor (both are valid non-error exits)
47
+ allow_exit_status 0..1
48
+
49
+ # @!method call(*, **)
50
+ #
51
+ # @overload call(*commit, **options)
52
+ #
53
+ # Execute the `git merge-base` command
54
+ #
55
+ # @param commit [Array<String>] two or more commit SHAs, branch names,
56
+ # or refs to find common ancestor(s) of
57
+ #
58
+ # @param options [Hash] command options
59
+ #
60
+ # @option options [Boolean, nil] :octopus (nil) compute best common
61
+ # ancestor for an n-way merge (intersection of all merge bases)
62
+ #
63
+ # @option options [Boolean, nil] :independent (nil) list commits not
64
+ # reachable from any other; useful for finding minimal merge points
65
+ #
66
+ # @option options [Boolean, nil] :is_ancestor (nil) check if the first
67
+ # commit is an ancestor of the second; exits 0 if true, 1 if not
68
+ #
69
+ # @option options [Boolean, nil] :fork_point (nil) find the fork point
70
+ # where a branch diverged from another, consulting the reflog
71
+ #
72
+ # @option options [Boolean, nil] :all (nil) output all merge bases instead
73
+ # of just one when multiple equally good bases exist
74
+ #
75
+ # Alias: :a
76
+ #
77
+ # @return [Git::CommandLineResult] the result of calling
78
+ # `git merge-base`
79
+ #
80
+ # @raise [ArgumentError] if unsupported options are provided
81
+ #
82
+ # @raise [Git::FailedError] if git exits outside the allowed range
83
+ # (exit code > 1)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements `git mv` to move or rename a file, a directory, or a symlink
8
+ #
9
+ # The index is updated after successful completion, but the change must still
10
+ # be committed.
11
+ #
12
+ # @example Move a single file
13
+ # mv = Git::Commands::Mv.new(execution_context)
14
+ # mv.call('old_name.rb', 'new_name.rb')
15
+ #
16
+ # @example Move multiple files to a directory
17
+ # mv = Git::Commands::Mv.new(execution_context)
18
+ # mv.call('file1.rb', 'file2.rb', 'destination_dir/')
19
+ #
20
+ # @example Force overwrite if destination exists
21
+ # mv = Git::Commands::Mv.new(execution_context)
22
+ # mv.call('source.rb', 'dest.rb', force: true)
23
+ #
24
+ # @note `arguments` block audited against https://git-scm.com/docs/git-mv/2.53.0
25
+ #
26
+ # @see https://git-scm.com/docs/git-mv git-mv
27
+ #
28
+ # @see Git::Commands
29
+ #
30
+ # @api private
31
+ #
32
+ class Mv < Git::Commands::Base
33
+ arguments do
34
+ literal 'mv'
35
+ flag_option %i[verbose v]
36
+ flag_option %i[force f]
37
+ flag_option %i[dry_run n]
38
+ flag_option :k
39
+ end_of_options
40
+ operand :source, repeatable: true, required: true
41
+ operand :destination, required: true
42
+ end
43
+
44
+ # @!method call(*, **)
45
+ #
46
+ # @overload call(*source, destination, **options)
47
+ #
48
+ # Execute the git mv command
49
+ #
50
+ # @param source [Array<String>] one or more source file(s) or directories to move
51
+ #
52
+ # @param destination [String] the destination file or directory
53
+ #
54
+ # @param options [Hash] command options
55
+ #
56
+ # @option options [Boolean, nil] :verbose (nil) report the names of files as they are moved
57
+ #
58
+ # Alias: `:v`
59
+ #
60
+ # @option options [Boolean, nil] :force (nil) force renaming or moving even if the destination exists
61
+ #
62
+ # Alias: `:f`
63
+ #
64
+ # @option options [Boolean, nil] :dry_run (nil) do nothing; only show what would happen
65
+ #
66
+ # Alias: `:n`
67
+ #
68
+ # @option options [Boolean, nil] :k (nil) skip move or rename actions which would lead to an error
69
+ #
70
+ # @return [Git::CommandLineResult] the result of calling `git mv`
71
+ #
72
+ # @raise [ArgumentError] if unsupported options are provided
73
+ #
74
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git name-rev` command
8
+ #
9
+ # Finds symbolic names suitable for human digestion for revisions given
10
+ # in any format parsable by `git rev-parse`.
11
+ #
12
+ # @example Find the symbolic name for a commit
13
+ # name_rev = Git::Commands::NameRev.new(execution_context)
14
+ # result = name_rev.call('abc123')
15
+ #
16
+ # @example Use only tags for naming
17
+ # name_rev = Git::Commands::NameRev.new(execution_context)
18
+ # result = name_rev.call('abc123', tags: true)
19
+ #
20
+ # @example List all commits reachable from all refs
21
+ # name_rev = Git::Commands::NameRev.new(execution_context)
22
+ # result = name_rev.call(all: true)
23
+ #
24
+ # @example Filter refs by pattern
25
+ # name_rev = Git::Commands::NameRev.new(execution_context)
26
+ # result = name_rev.call('abc123', refs: ['heads/*', 'tags/*'])
27
+ #
28
+ # @note `arguments` block audited against https://git-scm.com/docs/git-name-rev/2.53.0
29
+ #
30
+ # @see https://git-scm.com/docs/git-name-rev git-name-rev
31
+ #
32
+ # @api private
33
+ #
34
+ class NameRev < Git::Commands::Base
35
+ arguments do
36
+ literal 'name-rev'
37
+
38
+ # Ref filtering
39
+ flag_option :tags
40
+ value_option :refs, inline: true, repeatable: true
41
+ flag_option :no_refs
42
+ value_option :exclude, inline: true, repeatable: true
43
+ flag_option :no_exclude
44
+
45
+ # Output control
46
+ flag_option :all
47
+ flag_option :annotate_stdin
48
+ flag_option :name_only
49
+ flag_option :no_undefined
50
+ flag_option :always
51
+
52
+ end_of_options
53
+
54
+ operand :commit_ish, repeatable: true
55
+ end
56
+
57
+ # @!method call(*, **)
58
+ #
59
+ # @overload call(*commit_ish, **options)
60
+ #
61
+ # Execute the `git name-rev` command
62
+ #
63
+ # @param commit_ish [Array<String>] zero or more commit-ish objects
64
+ # to find symbolic names for
65
+ #
66
+ # @param options [Hash] command options
67
+ #
68
+ # @option options [Boolean, nil] :tags (nil) use only tags to name
69
+ # the commits, not branch names
70
+ #
71
+ # @option options [String, Array<String>] :refs (nil) only use refs
72
+ # whose names match the given shell pattern
73
+ #
74
+ # When given multiple times, uses refs whose names match any of the
75
+ # given shell patterns. Maps to `--refs=<pattern>`.
76
+ #
77
+ # @option options [Boolean, nil] :no_refs (nil) clear all previously given
78
+ # `--refs` patterns
79
+ #
80
+ # @option options [String, Array<String>] :exclude (nil) do not use
81
+ # any ref whose name matches the given shell pattern
82
+ #
83
+ # When given multiple times, a ref is excluded when it matches any
84
+ # of the given patterns. Maps to `--exclude=<pattern>`.
85
+ #
86
+ # @option options [Boolean, nil] :no_exclude (nil) clear all previously
87
+ # given `--exclude` patterns
88
+ #
89
+ # @option options [Boolean, nil] :all (nil) list all commits reachable
90
+ # from all refs
91
+ #
92
+ # @option options [Boolean, nil] :annotate_stdin (nil) transform stdin by
93
+ # substituting all 40-character SHA-1 hexes with their symbolic
94
+ # names. Maps to `--annotate-stdin`.
95
+ #
96
+ # @option options [Boolean, nil] :name_only (nil) print only the symbolic
97
+ # name, not the SHA-1
98
+ #
99
+ # @option options [Boolean, nil] :no_undefined (nil) die with non-zero
100
+ # exit code when a reference is undefined, instead of printing
101
+ # `undefined`
102
+ #
103
+ # @option options [Boolean, nil] :always (nil) show uniquely abbreviated
104
+ # commit object as fallback
105
+ #
106
+ # @return [Git::CommandLineResult] the result of calling
107
+ # `git name-rev`
108
+ #
109
+ # @raise [ArgumentError] if unsupported options are provided
110
+ #
111
+ # @raise [Git::FailedError] if git exits with a non-zero status
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,377 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git/commands/base'
4
+
5
+ module Git
6
+ module Commands
7
+ # Implements the `git pull` command
8
+ #
9
+ # Incorporates changes from a remote repository into the current branch.
10
+ # In its default mode, `git pull` is shorthand for `git fetch` followed
11
+ # by `git merge FETCH_HEAD`.
12
+ #
13
+ # @example Pull from the default remote
14
+ # pull = Git::Commands::Pull.new(execution_context)
15
+ # pull.call
16
+ #
17
+ # @example Pull from a named remote
18
+ # pull = Git::Commands::Pull.new(execution_context)
19
+ # pull.call('origin')
20
+ #
21
+ # @example Pull a specific branch from a remote
22
+ # pull = Git::Commands::Pull.new(execution_context)
23
+ # pull.call('origin', 'main')
24
+ #
25
+ # @example Pull with rebase instead of merge
26
+ # pull = Git::Commands::Pull.new(execution_context)
27
+ # pull.call('origin', rebase: true)
28
+ #
29
+ # @example Pull with allow-unrelated-histories
30
+ # pull = Git::Commands::Pull.new(execution_context)
31
+ # pull.call('origin', 'feature', allow_unrelated_histories: true)
32
+ #
33
+ # @example Pull and suppress the merge-commit editor
34
+ # pull = Git::Commands::Pull.new(execution_context)
35
+ # pull.call('origin', no_edit: true)
36
+ #
37
+ # @note `arguments` block audited against
38
+ # https://git-scm.com/docs/git-pull/2.53.0
39
+ #
40
+ # @see https://git-scm.com/docs/git-pull git-pull
41
+ #
42
+ # @see Git::Commands
43
+ #
44
+ # @api private
45
+ #
46
+ class Pull < Git::Commands::Base
47
+ arguments do
48
+ literal 'pull'
49
+
50
+ # General options
51
+ flag_option %i[quiet q]
52
+ flag_option %i[verbose v]
53
+ flag_or_value_option :recurse_submodules,
54
+ negatable: true, inline: true
55
+
56
+ # Merge options
57
+ flag_option :commit, negatable: true
58
+ flag_option %i[edit e], negatable: true
59
+ value_option :cleanup, inline: true
60
+ flag_option :ff_only
61
+ flag_option :ff, negatable: true
62
+ flag_or_value_option %i[gpg_sign S], negatable: true, inline: true
63
+ flag_or_value_option :log, negatable: true, inline: true
64
+ flag_option :signoff, negatable: true
65
+ flag_option :stat
66
+ flag_option %i[no_stat n]
67
+ flag_option :compact_summary
68
+ flag_option :squash, negatable: true
69
+ flag_option :verify, negatable: true
70
+ value_option %i[strategy s], inline: true
71
+ value_option %i[strategy_option X], inline: true, repeatable: true
72
+ flag_option :verify_signatures, negatable: true
73
+ flag_option :summary, negatable: true
74
+ flag_option :autostash, negatable: true
75
+ flag_option :allow_unrelated_histories
76
+ flag_or_value_option %i[rebase r], negatable: true, inline: true
77
+
78
+ # Fetch options
79
+ flag_option :all, negatable: true
80
+ flag_option %i[append a]
81
+ flag_option :atomic
82
+ value_option :depth, inline: true
83
+ value_option :deepen, inline: true
84
+ value_option :shallow_since, inline: true
85
+ value_option :shallow_exclude, inline: true, repeatable: true
86
+ flag_option :unshallow
87
+ flag_option :update_shallow
88
+ value_option :negotiation_tip, inline: true, repeatable: true
89
+ flag_option :negotiate_only
90
+ flag_option :dry_run
91
+ flag_option :porcelain
92
+ flag_option %i[force f]
93
+ flag_option %i[keep k]
94
+ flag_option :prefetch
95
+ flag_option %i[prune p]
96
+ flag_option %i[tags t], negatable: true
97
+ value_option :refmap, inline: true, repeatable: true
98
+ value_option %i[jobs j], inline: true
99
+ flag_option :set_upstream
100
+ value_option :upload_pack
101
+ flag_option :progress, negatable: true
102
+ value_option %i[server_option o], 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
+ # Execution options (not emitted as CLI flags)
108
+ execution_option :timeout
109
+
110
+ end_of_options
111
+ operand :repository
112
+ operand :refspec, repeatable: true
113
+ end
114
+
115
+ # @!method call(*, **)
116
+ #
117
+ # Execute the `git pull` command
118
+ #
119
+ # @overload call(repository = nil, *refspecs, **options)
120
+ #
121
+ # @param repository [String, nil] The remote name or URL to pull from
122
+ #
123
+ # When nil, git uses the default remote for the current branch.
124
+ #
125
+ # @param refspecs [Array<String>] Zero or more refspecs specifying which refs to fetch
126
+ # and merge
127
+ #
128
+ # Each may be a branch name or refspec pattern.
129
+ #
130
+ # @param options [Hash] command options
131
+ #
132
+ # @option options [Boolean, nil] :quiet (nil) suppress all output
133
+ #
134
+ # Alias: :q
135
+ #
136
+ # @option options [Boolean, nil] :verbose (nil) enable verbose output during fetch and merge
137
+ #
138
+ # Alias: :v
139
+ #
140
+ # @option options [Boolean, String, nil] :recurse_submodules (nil) control submodule
141
+ # commit fetching (`--recurse-submodules`)
142
+ #
143
+ # Pass a string such as `'yes'`, `'on-demand'`, or `'no'` for
144
+ # `--recurse-submodules=<value>`.
145
+ #
146
+ # @option options [Boolean, nil] :no_recurse_submodules (nil) disable submodule
147
+ # commit fetching (`--no-recurse-submodules`)
148
+ #
149
+ # @option options [Boolean, nil] :commit (nil) perform the merge and commit the result
150
+ # (`--commit`)
151
+ #
152
+ # @option options [Boolean, nil] :no_commit (nil) merge but do not commit the result
153
+ # (`--no-commit`)
154
+ #
155
+ # @option options [Boolean, nil] :edit (nil) open an editor for the merge commit message
156
+ # (`--edit`)
157
+ #
158
+ # Alias: :e
159
+ #
160
+ # @option options [Boolean, nil] :no_edit (nil) do not open an editor for the merge commit
161
+ # message (`--no-edit`)
162
+ #
163
+ # @option options [String] :cleanup (nil) merge-message cleanup mode
164
+ #
165
+ # Determines how the merge message is cleaned up before committing.
166
+ # For example, `'strip'`, `'whitespace'`, `'verbatim'`, `'scissors'`, `'default'`.
167
+ #
168
+ # @option options [Boolean, nil] :ff_only (nil) require fast-forward merge or up-to-date HEAD
169
+ #
170
+ # Refuses to merge unless the current HEAD is already up to date or the
171
+ # merge can be resolved as a fast-forward.
172
+ #
173
+ # @option options [Boolean, nil] :ff (nil) allow fast-forward merge (`--ff`)
174
+ #
175
+ # @option options [Boolean, nil] :no_ff (nil) disable fast-forward merge, always creating a
176
+ # merge commit (`--no-ff`)
177
+ #
178
+ # @option options [Boolean, String, nil] :gpg_sign (nil) GPG-sign the resulting merge commit
179
+ # (`--gpg-sign`)
180
+ #
181
+ # Pass a key-ID string to select the signing key. Alias: :S
182
+ #
183
+ # @option options [Boolean, nil] :no_gpg_sign (nil) countermand commit.gpgSign configuration
184
+ # (`--no-gpg-sign`)
185
+ #
186
+ # @option options [Boolean, Integer, nil] :log (nil) include one-line descriptions from
187
+ # the actual commits being merged in log message (`--log`)
188
+ #
189
+ # Pass an integer for `--log=<n>`.
190
+ #
191
+ # @option options [Boolean, nil] :no_log (nil) disable inclusion of one-line descriptions
192
+ # from merged commits (`--no-log`)
193
+ #
194
+ # @option options [Boolean, nil] :signoff (nil) add a `Signed-off-by` trailer to the
195
+ # resulting merge commit message (`--signoff`)
196
+ #
197
+ # @option options [Boolean, nil] :no_signoff (nil) remove a `Signed-off-by` trailer from
198
+ # the merge commit message (`--no-signoff`)
199
+ #
200
+ # @option options [Boolean, nil] :stat (nil) show a diffstat at the end of the merge
201
+ #
202
+ # @option options [Boolean, nil] :no_stat (nil) do not show a diffstat at the end of the merge
203
+ #
204
+ # Alias: :n
205
+ #
206
+ # @option options [Boolean, nil] :compact_summary (nil) show a compact summary after the merge
207
+ #
208
+ # @option options [Boolean, nil] :squash (nil) squash pulled commits into a single commit
209
+ # (`--squash`)
210
+ #
211
+ # @option options [Boolean, nil] :no_squash (nil) override `--squash` option (`--no-squash`)
212
+ #
213
+ # @option options [Boolean, nil] :verify (nil) run pre-merge and commit-msg hooks
214
+ # (`--verify`)
215
+ #
216
+ # @option options [Boolean, nil] :no_verify (nil) bypass pre-merge and commit-msg hooks
217
+ # (`--no-verify`)
218
+ #
219
+ # @option options [String] :strategy (nil) use the given merge strategy
220
+ #
221
+ # For example, `'ort'`, `'recursive'`, `'resolve'`, `'octopus'`, `'ours'`, `'subtree'`.
222
+ # Alias: :s
223
+ #
224
+ # @option options [String, Array<String>] :strategy_option (nil) pass option(s) to
225
+ # the merge strategy
226
+ #
227
+ # Can be a single value or array. For example, `'ours'`, `'theirs'`, `'patience'`.
228
+ # Alias: :X
229
+ #
230
+ # @option options [Boolean, nil] :verify_signatures (nil) verify that the tip commit of
231
+ # the side branch being merged is signed with a valid key (`--verify-signatures`)
232
+ #
233
+ # @option options [Boolean, nil] :no_verify_signatures (nil) do not verify the signature of
234
+ # the side branch tip commit (`--no-verify-signatures`)
235
+ #
236
+ # @option options [Boolean, nil] :summary (nil) show a summary after the merge (`--summary`)
237
+ #
238
+ # @option options [Boolean, nil] :no_summary (nil) do not show a summary after the merge
239
+ # (`--no-summary`)
240
+ #
241
+ # @option options [Boolean, nil] :autostash (nil) automatically create a temporary stash entry
242
+ # before the operation begins (`--autostash`)
243
+ #
244
+ # @option options [Boolean, nil] :no_autostash (nil) disable automatic stashing before the
245
+ # operation (`--no-autostash`)
246
+ #
247
+ # @option options [Boolean, nil] :allow_unrelated_histories (nil) allow pulling from a
248
+ # repository that shares no common history with the current repository
249
+ #
250
+ # @option options [Boolean, String, nil] :rebase (nil) rebase the current branch on
251
+ # top of the upstream branch after fetching (`--rebase`)
252
+ #
253
+ # Pass a string such as `'merges'` or `'interactive'` for `--rebase=<value>`.
254
+ # Alias: :r
255
+ #
256
+ # @option options [Boolean, nil] :no_rebase (nil) override earlier `--rebase` option
257
+ # (`--no-rebase`)
258
+ #
259
+ # @option options [Boolean, nil] :all (nil) fetch all remotes (`--all`)
260
+ #
261
+ # @option options [Boolean, nil] :no_all (nil) do not fetch all remotes (`--no-all`)
262
+ #
263
+ # @option options [Boolean, nil] :append (nil) append ref names and object names fetched to
264
+ # the existing contents of `.git/FETCH_HEAD`
265
+ #
266
+ # Alias: :a
267
+ #
268
+ # @option options [Boolean, nil] :atomic (nil) use an atomic transaction to update local refs
269
+ #
270
+ # @option options [String] :depth (nil) limit fetching to the given number of commits
271
+ #
272
+ # Fetches only the specified number of commits from the tip of each
273
+ # remote branch history.
274
+ #
275
+ # @option options [String] :deepen (nil) deepen or shorten history of a shallow repository
276
+ #
277
+ # @option options [String] :shallow_since (nil) deepen or shorten history to include all
278
+ # reachable commits after the given date
279
+ #
280
+ # @option options [String, Array<String>] :shallow_exclude (nil) exclude commits reachable
281
+ # from the specified remote branch or tag
282
+ #
283
+ # Repeatable.
284
+ #
285
+ # @option options [Boolean, nil] :unshallow (nil) convert a shallow repository to a complete one
286
+ #
287
+ # If the source is shallow, fetches as much as possible.
288
+ #
289
+ # @option options [Boolean, nil] :update_shallow (nil) accept refs that update `.git/shallow`
290
+ #
291
+ # @option options [String, Array<String>] :negotiation_tip (nil) report only commits
292
+ # reachable from the given tips during negotiation
293
+ #
294
+ # Repeatable.
295
+ #
296
+ # @option options [Boolean, nil] :negotiate_only (nil) do not fetch; only print ancestries
297
+ # between the local repository and the remote
298
+ #
299
+ # @option options [Boolean, nil] :dry_run (nil) show what would be done without making changes
300
+ #
301
+ # @option options [Boolean, nil] :porcelain (nil) give the output in a stable, easy-to-parse
302
+ # format for scripts
303
+ #
304
+ # @option options [Boolean, nil] :force (nil) override the check for a non-fast-forward update
305
+ #
306
+ # Alias: :f
307
+ #
308
+ # @option options [Boolean, nil] :keep (nil) keep the downloaded pack
309
+ #
310
+ # Alias: :k
311
+ #
312
+ # @option options [Boolean, nil] :prefetch (nil) modify the configured refspec to place
313
+ # all refs into the `refs/prefetch/` namespace
314
+ #
315
+ # @option options [Boolean, nil] :prune (nil) remove remote-tracking references that no longer
316
+ # exist on the remote before fetching
317
+ #
318
+ # Alias: :p
319
+ #
320
+ # @option options [Boolean, nil] :tags (nil) fetch all tags from the remote (`--tags`)
321
+ #
322
+ # Alias: :t
323
+ #
324
+ # @option options [Boolean, nil] :no_tags (nil) disable automatic tag following
325
+ # (`--no-tags`)
326
+ #
327
+ # @option options [String, Array<String>] :refmap (nil) override fetch refspecs for
328
+ # remote-tracking branch mapping
329
+ #
330
+ # Repeatable.
331
+ #
332
+ # @option options [String] :jobs (nil) number of submodules fetched in parallel
333
+ #
334
+ # Alias: :j
335
+ #
336
+ # @option options [Boolean, nil] :set_upstream (nil) add upstream (tracking) reference for
337
+ # the current branch
338
+ #
339
+ # @option options [String] :upload_pack (nil) path to `git-upload-pack` on the remote
340
+ #
341
+ # @option options [Boolean, nil] :progress (nil) force progress status display (`--progress`)
342
+ #
343
+ # @option options [Boolean, nil] :no_progress (nil) suppress progress status display
344
+ # (`--no-progress`)
345
+ #
346
+ # @option options [String, Array<String>] :server_option (nil) transmit the given
347
+ # string to the server when communicating using protocol version 2
348
+ #
349
+ # Repeatable. Alias: :o
350
+ #
351
+ # @option options [Boolean, nil] :show_forced_updates (nil) check whether a local branch is
352
+ # force-updated during fetch (`--show-forced-updates`)
353
+ #
354
+ # @option options [Boolean, nil] :no_show_forced_updates (nil) disable checking for force
355
+ # updates (`--no-show-forced-updates`)
356
+ #
357
+ # @option options [Boolean, nil] :ipv4 (nil) use IPv4 addresses only, ignoring IPv6 addresses
358
+ #
359
+ # Alias: :'4'
360
+ #
361
+ # @option options [Boolean, nil] :ipv6 (nil) use IPv6 addresses only, ignoring IPv4 addresses
362
+ #
363
+ # Alias: :'6'
364
+ #
365
+ # @option options [Numeric, nil] :timeout (nil) timeout in seconds for the command
366
+ #
367
+ # If nil, uses the global timeout from {Git::Config}.
368
+ #
369
+ # @return [Git::CommandLineResult] the result of calling `git pull`
370
+ #
371
+ # @raise [ArgumentError] if argument validation fails (e.g., unsupported options
372
+ # are provided or option values are invalid)
373
+ #
374
+ # @raise [Git::FailedError] if git exits with a non-zero exit status
375
+ end
376
+ end
377
+ end