git 5.0.0.beta.2 → 5.0.0.beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +27 -0
  3. data/.github/copilot-instructions.md +3 -8
  4. data/.github/hooks/bin-setup-on-worktree.json +11 -0
  5. data/.github/hooks/run-bin-setup-once.sh +14 -0
  6. data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
  7. data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
  8. data/.github/skills/command-implementation/REFERENCE.md +34 -33
  9. data/.github/skills/command-implementation/SKILL.md +5 -4
  10. data/.github/skills/command-test-conventions/SKILL.md +13 -9
  11. data/.github/skills/command-yard-documentation/SKILL.md +14 -6
  12. data/.github/skills/development-workflow/SKILL.md +20 -14
  13. data/.github/skills/facade-implementation/REFERENCE.md +19 -22
  14. data/.github/skills/facade-implementation/SKILL.md +0 -5
  15. data/.github/skills/facade-test-conventions/SKILL.md +4 -7
  16. data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
  17. data/.github/skills/make-skill-template/SKILL.md +53 -3
  18. data/.github/skills/pr-readiness-review/SKILL.md +22 -2
  19. data/.github/skills/project-context/SKILL.md +16 -23
  20. data/.github/skills/pull-request-review/SKILL.md +2 -2
  21. data/.github/skills/rebase/SKILL.md +148 -0
  22. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
  23. data/.github/skills/resolve-feedback/SKILL.md +288 -0
  24. data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
  25. data/.github/skills/reviewing-skills/SKILL.md +28 -3
  26. data/.github/skills/test-debugging/SKILL.md +20 -19
  27. data/.github/skills/yard-documentation/SKILL.md +671 -483
  28. data/.github/skills/yard-documentation/element-rules.md +162 -0
  29. data/.github/skills-deprecated/README.md +21 -0
  30. data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
  31. data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
  32. data/.github/workflows/continuous_integration.yml +3 -2
  33. data/.rubocop.yml +7 -39
  34. data/.yard-lint.yml +75 -0
  35. data/CONTRIBUTING.md +186 -174
  36. data/Gemfile +17 -0
  37. data/README.md +86 -23
  38. data/Rakefile +3 -21
  39. data/UPGRADING.md +219 -70
  40. data/docker/test/Dockerfile +32 -0
  41. data/docker/test/docker-compose.yml +0 -0
  42. data/git.gemspec +3 -4
  43. data/lib/git/author.rb +20 -1
  44. data/lib/git/branch.rb +26 -6
  45. data/lib/git/branch_delete_failure.rb +3 -0
  46. data/lib/git/branch_delete_result.rb +6 -3
  47. data/lib/git/branch_info.rb +6 -6
  48. data/lib/git/command_line/base.rb +6 -13
  49. data/lib/git/command_line/capturing.rb +67 -10
  50. data/lib/git/command_line/result.rb +0 -8
  51. data/lib/git/command_line/streaming.rb +45 -5
  52. data/lib/git/command_line.rb +4 -3
  53. data/lib/git/commands/add.rb +61 -53
  54. data/lib/git/commands/am/abort.rb +2 -2
  55. data/lib/git/commands/am/apply.rb +109 -98
  56. data/lib/git/commands/am/continue.rb +2 -2
  57. data/lib/git/commands/am/quit.rb +2 -2
  58. data/lib/git/commands/am/retry.rb +4 -2
  59. data/lib/git/commands/am/show_current_patch.rb +1 -1
  60. data/lib/git/commands/am/skip.rb +2 -2
  61. data/lib/git/commands/am.rb +2 -2
  62. data/lib/git/commands/apply.rb +7 -2
  63. data/lib/git/commands/archive/list_formats.rb +3 -3
  64. data/lib/git/commands/archive.rb +7 -2
  65. data/lib/git/commands/arguments.rb +1370 -359
  66. data/lib/git/commands/base.rb +111 -13
  67. data/lib/git/commands/branch/copy.rb +29 -21
  68. data/lib/git/commands/branch/create.rb +72 -68
  69. data/lib/git/commands/branch/delete.rb +25 -17
  70. data/lib/git/commands/branch/list.rb +76 -60
  71. data/lib/git/commands/branch/move.rb +29 -21
  72. data/lib/git/commands/branch/set_upstream.rb +8 -8
  73. data/lib/git/commands/branch/show_current.rb +3 -3
  74. data/lib/git/commands/branch/unset_upstream.rb +4 -8
  75. data/lib/git/commands/branch.rb +2 -2
  76. data/lib/git/commands/cat_file/batch.rb +36 -20
  77. data/lib/git/commands/cat_file/filtered.rb +12 -12
  78. data/lib/git/commands/cat_file/raw.rb +13 -13
  79. data/lib/git/commands/cat_file.rb +4 -4
  80. data/lib/git/commands/checkout/branch.rb +7 -5
  81. data/lib/git/commands/checkout/files.rb +5 -4
  82. data/lib/git/commands/checkout.rb +4 -4
  83. data/lib/git/commands/checkout_index.rb +5 -4
  84. data/lib/git/commands/clean.rb +6 -4
  85. data/lib/git/commands/clone.rb +5 -4
  86. data/lib/git/commands/commit.rb +5 -4
  87. data/lib/git/commands/commit_tree.rb +5 -4
  88. data/lib/git/commands/config_option_syntax/add.rb +7 -4
  89. data/lib/git/commands/config_option_syntax/get.rb +9 -5
  90. data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
  91. data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
  92. data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
  93. data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
  94. data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
  95. data/lib/git/commands/config_option_syntax/list.rb +8 -4
  96. data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
  97. data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
  98. data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
  99. data/lib/git/commands/config_option_syntax/set.rb +7 -2
  100. data/lib/git/commands/config_option_syntax/unset.rb +7 -4
  101. data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
  102. data/lib/git/commands/describe.rb +5 -4
  103. data/lib/git/commands/diff.rb +13 -12
  104. data/lib/git/commands/diff_files.rb +7 -6
  105. data/lib/git/commands/diff_index.rb +10 -7
  106. data/lib/git/commands/fetch.rb +6 -4
  107. data/lib/git/commands/fsck.rb +6 -4
  108. data/lib/git/commands/gc.rb +6 -4
  109. data/lib/git/commands/grep.rb +6 -5
  110. data/lib/git/commands/init.rb +6 -4
  111. data/lib/git/commands/log.rb +287 -285
  112. data/lib/git/commands/ls_files.rb +69 -65
  113. data/lib/git/commands/ls_remote.rb +62 -56
  114. data/lib/git/commands/ls_tree.rb +50 -46
  115. data/lib/git/commands/maintenance/register.rb +25 -23
  116. data/lib/git/commands/maintenance/run.rb +7 -2
  117. data/lib/git/commands/maintenance/start.rb +7 -2
  118. data/lib/git/commands/maintenance/stop.rb +7 -2
  119. data/lib/git/commands/maintenance/unregister.rb +7 -2
  120. data/lib/git/commands/merge/abort.rb +2 -2
  121. data/lib/git/commands/merge/continue.rb +2 -2
  122. data/lib/git/commands/merge/quit.rb +2 -2
  123. data/lib/git/commands/merge/start.rb +7 -2
  124. data/lib/git/commands/merge.rb +2 -2
  125. data/lib/git/commands/merge_base.rb +7 -2
  126. data/lib/git/commands/mv.rb +7 -2
  127. data/lib/git/commands/name_rev.rb +7 -2
  128. data/lib/git/commands/pull.rb +7 -2
  129. data/lib/git/commands/push.rb +7 -2
  130. data/lib/git/commands/read_tree.rb +7 -2
  131. data/lib/git/commands/remote/add.rb +7 -2
  132. data/lib/git/commands/remote/get_url.rb +4 -2
  133. data/lib/git/commands/remote/list.rb +4 -2
  134. data/lib/git/commands/remote/prune.rb +4 -2
  135. data/lib/git/commands/remote/remove.rb +4 -2
  136. data/lib/git/commands/remote/rename.rb +4 -2
  137. data/lib/git/commands/remote/set_branches.rb +9 -2
  138. data/lib/git/commands/remote/set_head.rb +12 -5
  139. data/lib/git/commands/remote/set_url.rb +9 -2
  140. data/lib/git/commands/remote/set_url_add.rb +11 -2
  141. data/lib/git/commands/remote/set_url_delete.rb +9 -2
  142. data/lib/git/commands/remote/show.rb +18 -12
  143. data/lib/git/commands/remote/update.rb +19 -12
  144. data/lib/git/commands/remote.rb +2 -2
  145. data/lib/git/commands/repack.rb +67 -63
  146. data/lib/git/commands/reset.rb +51 -44
  147. data/lib/git/commands/rev_parse.rb +135 -128
  148. data/lib/git/commands/revert/abort.rb +2 -2
  149. data/lib/git/commands/revert/continue.rb +7 -2
  150. data/lib/git/commands/revert/quit.rb +2 -2
  151. data/lib/git/commands/revert/skip.rb +2 -2
  152. data/lib/git/commands/revert/start.rb +7 -2
  153. data/lib/git/commands/revert.rb +2 -2
  154. data/lib/git/commands/rm.rb +35 -36
  155. data/lib/git/commands/show.rb +1 -1
  156. data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
  157. data/lib/git/commands/show_ref/exists.rb +15 -13
  158. data/lib/git/commands/show_ref/list.rb +39 -35
  159. data/lib/git/commands/show_ref/verify.rb +29 -27
  160. data/lib/git/commands/show_ref.rb +4 -4
  161. data/lib/git/commands/stash/apply.rb +31 -25
  162. data/lib/git/commands/stash/branch.rb +10 -8
  163. data/lib/git/commands/stash/clear.rb +7 -5
  164. data/lib/git/commands/stash/create.rb +10 -8
  165. data/lib/git/commands/stash/drop.rb +15 -9
  166. data/lib/git/commands/stash/list.rb +9 -5
  167. data/lib/git/commands/stash/pop.rb +21 -12
  168. data/lib/git/commands/stash/push.rb +20 -11
  169. data/lib/git/commands/stash/show.rb +21 -12
  170. data/lib/git/commands/stash/store.rb +19 -10
  171. data/lib/git/commands/stash.rb +2 -2
  172. data/lib/git/commands/status.rb +7 -2
  173. data/lib/git/commands/symbolic_ref/delete.rb +18 -14
  174. data/lib/git/commands/symbolic_ref/read.rb +24 -20
  175. data/lib/git/commands/symbolic_ref/update.rb +20 -17
  176. data/lib/git/commands/symbolic_ref.rb +4 -4
  177. data/lib/git/commands/tag/create.rb +45 -42
  178. data/lib/git/commands/tag/delete.rb +5 -3
  179. data/lib/git/commands/tag/list.rb +47 -44
  180. data/lib/git/commands/tag/verify.rb +12 -12
  181. data/lib/git/commands/tag.rb +2 -2
  182. data/lib/git/commands/update_ref/batch.rb +6 -1
  183. data/lib/git/commands/update_ref/delete.rb +19 -21
  184. data/lib/git/commands/update_ref/update.rb +22 -25
  185. data/lib/git/commands/update_ref.rb +4 -4
  186. data/lib/git/commands/version.rb +14 -11
  187. data/lib/git/commands/worktree/add.rb +50 -51
  188. data/lib/git/commands/worktree/list.rb +17 -17
  189. data/lib/git/commands/worktree/lock.rb +12 -12
  190. data/lib/git/commands/worktree/move.rb +16 -16
  191. data/lib/git/commands/worktree/prune.rb +2 -2
  192. data/lib/git/commands/worktree/remove.rb +2 -2
  193. data/lib/git/commands/worktree/repair.rb +2 -2
  194. data/lib/git/commands/worktree/unlock.rb +2 -2
  195. data/lib/git/commands/write_tree.rb +2 -2
  196. data/lib/git/commands.rb +4 -3
  197. data/lib/git/config.rb +47 -1
  198. data/lib/git/configuring.rb +89 -15
  199. data/lib/git/detached_head_info.rb +4 -1
  200. data/lib/git/diff.rb +2 -5
  201. data/lib/git/diff_file_numstat_info.rb +3 -1
  202. data/lib/git/diff_file_patch_info.rb +3 -1
  203. data/lib/git/diff_file_raw_info.rb +3 -1
  204. data/lib/git/diff_info.rb +8 -15
  205. data/lib/git/diff_path_status.rb +16 -3
  206. data/lib/git/diff_result.rb +3 -1
  207. data/lib/git/diff_stats.rb +15 -0
  208. data/lib/git/dirstat_info.rb +24 -8
  209. data/lib/git/encoding_utils.rb +32 -1
  210. data/lib/git/errors.rb +19 -9
  211. data/lib/git/escaped_path.rb +55 -3
  212. data/lib/git/execution_context/repository.rb +15 -0
  213. data/lib/git/execution_context.rb +76 -74
  214. data/lib/git/file_ref.rb +6 -3
  215. data/lib/git/fsck_object.rb +8 -0
  216. data/lib/git/fsck_result.rb +26 -15
  217. data/lib/git/log.rb +152 -5
  218. data/lib/git/object.rb +284 -8
  219. data/lib/git/parsers/branch.rb +18 -0
  220. data/lib/git/parsers/cat_file.rb +2 -2
  221. data/lib/git/parsers/diff.rb +213 -5
  222. data/lib/git/parsers/fsck.rb +11 -0
  223. data/lib/git/parsers/ls_remote.rb +1 -1
  224. data/lib/git/parsers/stash.rb +51 -0
  225. data/lib/git/parsers/tag.rb +38 -0
  226. data/lib/git/remote.rb +34 -2
  227. data/lib/git/repository/branching.rb +23 -21
  228. data/lib/git/repository/committing.rb +46 -6
  229. data/lib/git/repository/context_helpers.rb +45 -16
  230. data/lib/git/repository/diffing.rb +32 -23
  231. data/lib/git/repository/factories.rb +153 -28
  232. data/lib/git/repository/inspecting.rb +1 -1
  233. data/lib/git/repository/logging.rb +169 -30
  234. data/lib/git/repository/maintenance.rb +1 -1
  235. data/lib/git/repository/merging.rb +3 -3
  236. data/lib/git/repository/object_operations.rb +108 -14
  237. data/lib/git/repository/remote_operations.rb +150 -171
  238. data/lib/git/repository/shared_private.rb +7 -5
  239. data/lib/git/repository/staging.rb +36 -12
  240. data/lib/git/repository/stashing.rb +16 -16
  241. data/lib/git/repository/status_operations.rb +1 -1
  242. data/lib/git/repository/worktree_operations.rb +1 -1
  243. data/lib/git/repository.rb +287 -6
  244. data/lib/git/stash.rb +16 -21
  245. data/lib/git/stash_info.rb +4 -4
  246. data/lib/git/stashes.rb +20 -26
  247. data/lib/git/status.rb +25 -13
  248. data/lib/git/tag_delete_failure.rb +3 -0
  249. data/lib/git/tag_delete_result.rb +6 -3
  250. data/lib/git/tag_info.rb +1 -0
  251. data/lib/git/url.rb +12 -5
  252. data/lib/git/version.rb +6 -4
  253. data/lib/git/version_constraint.rb +4 -0
  254. data/lib/git.rb +400 -314
  255. data/redesign/3_architecture_implementation.md +81 -30
  256. data/redesign/Phase 4 - Step A.md +6 -0
  257. data/redesign/Phase 4 - Step B.md +921 -0
  258. data/redesign/Phase 4 - Step C.md +833 -0
  259. data/redesign/c1a-public-api-scope.tsv +256 -0
  260. data/redesign/phase-4-step-b-test-audit.tsv +485 -0
  261. data/tasks/yard.rake +24 -17
  262. metadata +24 -58
  263. data/commitlint.test +0 -4
  264. data/lib/git/args_builder.rb +0 -103
  265. data/lib/git/command_line_result.rb +0 -8
  266. data/lib/git/deprecation.rb +0 -9
  267. data/lib/git/repository/configuring.rb +0 -351
  268. data/tasks/test.rake +0 -25
  269. /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
  270. /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
@@ -10,26 +10,32 @@ module Git
10
10
  #
11
11
  class FsckResult
12
12
  # Objects not referenced by any other object
13
+ #
13
14
  # @return [Array<Git::FsckObject>]
14
15
  attr_reader :dangling
15
16
 
16
17
  # Objects that are referenced but not present in the repository
18
+ #
17
19
  # @return [Array<Git::FsckObject>]
18
20
  attr_reader :missing
19
21
 
20
22
  # Objects not reachable from any ref
23
+ #
21
24
  # @return [Array<Git::FsckObject>]
22
25
  attr_reader :unreachable
23
26
 
24
27
  # Objects with warnings (each includes a message)
28
+ #
25
29
  # @return [Array<Git::FsckObject>]
26
30
  attr_reader :warnings
27
31
 
28
32
  # Root nodes (commits with no parents) when --root is used
33
+ #
29
34
  # @return [Array<Git::FsckObject>]
30
35
  attr_reader :root
31
36
 
32
37
  # Tagged objects when --tags is used
38
+ #
33
39
  # @return [Array<Git::FsckObject>]
34
40
  attr_reader :tagged
35
41
 
@@ -38,10 +44,15 @@ module Git
38
44
  # Create a new FsckResult
39
45
  #
40
46
  # @param dangling [Array<Git::FsckObject>] dangling objects
47
+ #
41
48
  # @param missing [Array<Git::FsckObject>] missing objects
49
+ #
42
50
  # @param unreachable [Array<Git::FsckObject>] unreachable objects
51
+ #
43
52
  # @param warnings [Array<Git::FsckObject>] objects with warnings
53
+ #
44
54
  # @param root [Array<Git::FsckObject>] root nodes
55
+ #
45
56
  # @param tagged [Array<Git::FsckObject>] tagged objects
46
57
  #
47
58
  def initialize(dangling: [], missing: [], unreachable: [], warnings: [], root: [], tagged: [])
@@ -57,60 +68,60 @@ module Git
57
68
 
58
69
  # Returns true if any issues were found
59
70
  #
60
- # @return [Boolean]
61
- #
62
- # @example
71
+ # @example Check for repository issues
63
72
  # result = git.fsck
64
73
  # puts "Repository has issues!" if result.any_issues?
65
74
  #
75
+ # @return [Boolean]
76
+ #
66
77
  def any_issues?
67
78
  [dangling, missing, unreachable, warnings].any?(&:any?)
68
79
  end
69
80
 
70
81
  # Returns true if no issues were found
71
82
  #
72
- # @return [Boolean]
73
- #
74
- # @example
83
+ # @example Check if the result is empty
75
84
  # result = git.fsck
76
85
  # puts "Repository is clean" if result.empty?
77
86
  #
87
+ # @return [Boolean]
88
+ #
78
89
  def empty?
79
90
  !any_issues?
80
91
  end
81
92
 
82
93
  # Returns all objects from all categories (excluding informational root/tagged)
83
94
  #
84
- # @return [Array<Git::FsckObject>]
85
- #
86
- # @example
95
+ # @example Iterate over all objects
87
96
  # result = git.fsck
88
97
  # result.all_objects.each { |obj| puts obj.oid }
89
98
  #
99
+ # @return [Array<Git::FsckObject>]
100
+ #
90
101
  def all_objects
91
102
  dangling + missing + unreachable + warnings
92
103
  end
93
104
 
94
105
  # Returns the total number of issues found
95
106
  #
96
- # @return [Integer]
97
- #
98
- # @example
107
+ # @example Count all issues
99
108
  # result = git.fsck
100
109
  # puts "Found #{result.count} issues"
101
110
  #
111
+ # @return [Integer]
112
+ #
102
113
  def count
103
114
  all_objects.size
104
115
  end
105
116
 
106
117
  # Returns a hash representation of the result
107
118
  #
108
- # @return [Hash{Symbol => Array<Git::FsckObject>}]
109
- #
110
- # @example
119
+ # @example Convert to a hash
111
120
  # result = git.fsck
112
121
  # result.to_h # => { dangling: [...], missing: [...], ... }
113
122
  #
123
+ # @return [Hash{Symbol => Array<Git::FsckObject>}]
124
+ #
114
125
  def to_h
115
126
  {
116
127
  dangling: dangling, missing: missing, unreachable: unreachable,
data/lib/git/log.rb CHANGED
@@ -25,14 +25,58 @@ module Git
25
25
 
26
26
  # An immutable, Enumerable collection of `Git::Object::Commit` objects.
27
27
  # Returned by `Git::Log#execute`.
28
+ #
28
29
  # @api public
29
30
  Result = Data.define(:commits) do
30
31
  include Enumerable
31
32
 
33
+ # Iterates over each commit in query order
34
+ #
35
+ # @overload each
36
+ # @example Get an enumerator
37
+ # results.each.map(&:sha)
38
+ #
39
+ # @return [Enumerator<Git::Object::Commit>] an enumerator over commits
40
+ #
41
+ # @overload each(&block)
42
+ # @example Iterate with a block
43
+ # results.each { |commit| puts commit.sha }
44
+ #
45
+ # @yield [commit] each commit from the result
46
+ #
47
+ # @yieldparam commit [Git::Object::Commit] a commit in query order
48
+ #
49
+ # @yieldreturn [void]
50
+ #
51
+ # @return [Array<Git::Object::Commit>] the commit array
52
+ #
32
53
  def each(&block) = commits.each(&block)
54
+
55
+ # Returns the last commit in the result
56
+ #
57
+ # @return [Git::Object::Commit, nil] the last commit, or `nil` when empty
58
+ #
33
59
  def last = commits.last
60
+
61
+ # Returns a commit by index or a slice of commits by range
62
+ #
63
+ # @param index [Integer, Range] the commit index or range to retrieve
64
+ #
65
+ # @return [Git::Object::Commit, Array<Git::Object::Commit>, nil] the selected
66
+ # commit or commits
67
+ #
34
68
  def [](index) = commits[index]
69
+
70
+ # Returns the commits joined with newlines
71
+ #
72
+ # @return [String] newline-separated commits
73
+ #
35
74
  def to_s = commits.join("\n")
75
+
76
+ # Returns the number of commits in the result
77
+ #
78
+ # @return [Integer] the commit count
79
+ #
36
80
  def size = commits.size
37
81
  end
38
82
 
@@ -59,17 +103,98 @@ module Git
59
103
  # Set query options using a fluent interface.
60
104
  # Each method returns `self` to allow for chaining.
61
105
  #
106
+ # Sets the maximum number of commits to return
107
+ #
108
+ # @param num [Integer, Symbol, nil] the maximum commit count, or `:all` / `nil`
109
+ # for no limit
110
+ #
111
+ # @return [Git::Log] the current query builder
112
+ #
62
113
  def max_count(num) = set_option(:count, num == :all ? nil : num)
114
+
115
+ # Includes commits reachable from all refs
116
+ #
117
+ # @return [Git::Log] the current query builder
118
+ #
63
119
  def all = set_option(:all, true)
120
+
121
+ # Sets the revision range expression for the log query
122
+ #
123
+ # @param objectish [String] a git revision expression to pass to `git log`
124
+ #
125
+ # @return [Git::Log] the current query builder
126
+ #
64
127
  def object(objectish) = set_option(:object, objectish)
128
+
129
+ # Filters commits by author pattern
130
+ #
131
+ # @param regex [String] a pattern matched against author names
132
+ #
133
+ # @return [Git::Log] the current query builder
134
+ #
65
135
  def author(regex) = set_option(:author, regex)
136
+
137
+ # Filters commits by commit message pattern
138
+ #
139
+ # @param regex [String] a pattern matched against commit messages
140
+ #
141
+ # @return [Git::Log] the current query builder
142
+ #
66
143
  def grep(regex) = set_option(:grep, regex)
144
+
145
+ # Limits commits to those that touch the given path or paths
146
+ #
147
+ # @param path [String, Pathname, Array<String, Pathname>] path limiter input
148
+ #
149
+ # @return [Git::Log] the current query builder
150
+ #
67
151
  def path(path) = set_option(:path_limiter, path)
152
+
153
+ # Skips a number of commits before returning results
154
+ #
155
+ # @param num [Integer] the number of commits to skip
156
+ #
157
+ # @return [Git::Log] the current query builder
158
+ #
68
159
  def skip(num) = set_option(:skip, num)
160
+
161
+ # Includes only commits newer than the given date expression
162
+ #
163
+ # @param date [String] a git-compatible date expression
164
+ #
165
+ # @return [Git::Log] the current query builder
166
+ #
69
167
  def since(date) = set_option(:since, date)
168
+
169
+ # Includes only commits older than the given date expression
170
+ #
171
+ # @param date [String] a git-compatible date expression
172
+ #
173
+ # @return [Git::Log] the current query builder
174
+ #
70
175
  def until(date) = set_option(:until, date)
176
+
177
+ # Limits commits to the given revision range
178
+ #
179
+ # @param val1 [String] the first revision
180
+ #
181
+ # @param val2 [String, nil] the second revision; when `nil`, validation fails
182
+ # at execution time
183
+ #
184
+ # @return [Git::Log] the current query builder
185
+ #
71
186
  def between(val1, val2 = nil) = set_option(:between, [val1, val2])
187
+
188
+ # Omits commits equivalent to cherry-picked commits
189
+ #
190
+ # @return [Git::Log] the current query builder
191
+ #
72
192
  def cherry = set_option(:cherry, true)
193
+
194
+ # Includes only merge commits
195
+ #
196
+ # @return [Git::Log] the current query builder
197
+ #
73
198
  def merges = set_option(:merges, true)
74
199
 
75
200
  # Executes the git log command and returns an immutable result object
@@ -109,7 +234,7 @@ module Git
109
234
  'Calling Git::Log#size is deprecated. Call #execute and then #size on the result object.'
110
235
  )
111
236
  run_log_if_dirty
112
- @commits&.size
237
+ @commits.size
113
238
  end
114
239
 
115
240
  # @deprecated Use {#execute} and call `to_s` on the result.
@@ -118,7 +243,7 @@ module Git
118
243
  'Calling Git::Log#to_s is deprecated. Call #execute and then #to_s on the result object.'
119
244
  )
120
245
  run_log_if_dirty
121
- @commits&.join("\n")
246
+ @commits.join("\n")
122
247
  end
123
248
 
124
249
  # @deprecated Use {#execute} and call the method on the result.
@@ -127,7 +252,7 @@ module Git
127
252
  'Calling Git::Log#first is deprecated. Call #execute and then #first on the result object.'
128
253
  )
129
254
  run_log_if_dirty
130
- @commits&.first
255
+ @commits.first
131
256
  end
132
257
 
133
258
  # @deprecated Use {#execute} and call the method on the result.
@@ -136,22 +261,36 @@ module Git
136
261
  'Calling Git::Log#last is deprecated. Call #execute and then #last on the result object.'
137
262
  )
138
263
  run_log_if_dirty
139
- @commits&.last
264
+ @commits.last
140
265
  end
141
266
 
267
+ # @param index [Integer, Range] the commit index or range to retrieve
268
+ #
269
+ # @return [Git::Object::Commit, Array<Git::Object::Commit>, nil] the selected
270
+ # commit or commits
271
+ #
142
272
  # @deprecated Use {#execute} and call the method on the result.
273
+ #
143
274
  def [](index)
144
275
  Git::Deprecation.warn(
145
276
  'Calling Git::Log#[] is deprecated. Call #execute and then #[] on the result object.'
146
277
  )
147
278
  run_log_if_dirty
148
- @commits&.[](index)
279
+ @commits[index]
149
280
  end
150
281
 
151
282
  # @!endgroup
152
283
 
153
284
  private
154
285
 
286
+ # Sets a log query option and marks cached results dirty
287
+ #
288
+ # @param key [Symbol] the option key
289
+ #
290
+ # @param value [Object] the option value
291
+ #
292
+ # @return [Git::Log] the current query builder
293
+ #
155
294
  def set_option(key, value)
156
295
  @dirty = true
157
296
  @options[key] = value
@@ -164,6 +303,14 @@ module Git
164
303
  @base
165
304
  end
166
305
 
306
+ # Refreshes cached commits when query options have changed
307
+ #
308
+ # @return [void]
309
+ #
310
+ # @raise [ArgumentError] if configured query options are invalid
311
+ #
312
+ # @raise [Git::FailedError] if the underlying `git log` command fails
313
+ #
167
314
  def run_log_if_dirty
168
315
  return unless @dirty
169
316