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.
- checksums.yaml +4 -4
- data/.dockerignore +27 -0
- data/.github/copilot-instructions.md +3 -8
- data/.github/hooks/bin-setup-on-worktree.json +11 -0
- data/.github/hooks/run-bin-setup-once.sh +14 -0
- data/.github/skills/breaking-change-analysis/SKILL.md +6 -9
- data/.github/skills/ci-cd-troubleshooting/SKILL.md +2 -2
- data/.github/skills/command-implementation/REFERENCE.md +34 -33
- data/.github/skills/command-implementation/SKILL.md +5 -4
- data/.github/skills/command-test-conventions/SKILL.md +13 -9
- data/.github/skills/command-yard-documentation/SKILL.md +14 -6
- data/.github/skills/development-workflow/SKILL.md +20 -14
- data/.github/skills/facade-implementation/REFERENCE.md +19 -22
- data/.github/skills/facade-implementation/SKILL.md +0 -5
- data/.github/skills/facade-test-conventions/SKILL.md +4 -7
- data/.github/skills/facade-yard-documentation/SKILL.md +8 -2
- data/.github/skills/make-skill-template/SKILL.md +53 -3
- data/.github/skills/pr-readiness-review/SKILL.md +22 -2
- data/.github/skills/project-context/SKILL.md +16 -23
- data/.github/skills/pull-request-review/SKILL.md +2 -2
- data/.github/skills/rebase/SKILL.md +148 -0
- data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +1 -1
- data/.github/skills/resolve-feedback/SKILL.md +288 -0
- data/.github/skills/review-arguments-dsl/CHECKLIST.md +3 -3
- data/.github/skills/reviewing-skills/SKILL.md +28 -3
- data/.github/skills/test-debugging/SKILL.md +20 -19
- data/.github/skills/yard-documentation/SKILL.md +671 -483
- data/.github/skills/yard-documentation/element-rules.md +162 -0
- data/.github/skills-deprecated/README.md +21 -0
- data/.github/{skills → skills-deprecated}/extract-command-from-lib/SKILL.md +9 -9
- data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/SKILL.md +12 -12
- data/.github/workflows/continuous_integration.yml +3 -2
- data/.rubocop.yml +7 -39
- data/.yard-lint.yml +75 -0
- data/CONTRIBUTING.md +186 -174
- data/Gemfile +17 -0
- data/README.md +86 -23
- data/Rakefile +3 -21
- data/UPGRADING.md +219 -70
- data/docker/test/Dockerfile +32 -0
- data/docker/test/docker-compose.yml +0 -0
- data/git.gemspec +3 -4
- data/lib/git/author.rb +20 -1
- data/lib/git/branch.rb +26 -6
- data/lib/git/branch_delete_failure.rb +3 -0
- data/lib/git/branch_delete_result.rb +6 -3
- data/lib/git/branch_info.rb +6 -6
- data/lib/git/command_line/base.rb +6 -13
- data/lib/git/command_line/capturing.rb +67 -10
- data/lib/git/command_line/result.rb +0 -8
- data/lib/git/command_line/streaming.rb +45 -5
- data/lib/git/command_line.rb +4 -3
- data/lib/git/commands/add.rb +61 -53
- data/lib/git/commands/am/abort.rb +2 -2
- data/lib/git/commands/am/apply.rb +109 -98
- data/lib/git/commands/am/continue.rb +2 -2
- data/lib/git/commands/am/quit.rb +2 -2
- data/lib/git/commands/am/retry.rb +4 -2
- data/lib/git/commands/am/show_current_patch.rb +1 -1
- data/lib/git/commands/am/skip.rb +2 -2
- data/lib/git/commands/am.rb +2 -2
- data/lib/git/commands/apply.rb +7 -2
- data/lib/git/commands/archive/list_formats.rb +3 -3
- data/lib/git/commands/archive.rb +7 -2
- data/lib/git/commands/arguments.rb +1370 -359
- data/lib/git/commands/base.rb +111 -13
- data/lib/git/commands/branch/copy.rb +29 -21
- data/lib/git/commands/branch/create.rb +72 -68
- data/lib/git/commands/branch/delete.rb +25 -17
- data/lib/git/commands/branch/list.rb +76 -60
- data/lib/git/commands/branch/move.rb +29 -21
- data/lib/git/commands/branch/set_upstream.rb +8 -8
- data/lib/git/commands/branch/show_current.rb +3 -3
- data/lib/git/commands/branch/unset_upstream.rb +4 -8
- data/lib/git/commands/branch.rb +2 -2
- data/lib/git/commands/cat_file/batch.rb +36 -20
- data/lib/git/commands/cat_file/filtered.rb +12 -12
- data/lib/git/commands/cat_file/raw.rb +13 -13
- data/lib/git/commands/cat_file.rb +4 -4
- data/lib/git/commands/checkout/branch.rb +7 -5
- data/lib/git/commands/checkout/files.rb +5 -4
- data/lib/git/commands/checkout.rb +4 -4
- data/lib/git/commands/checkout_index.rb +5 -4
- data/lib/git/commands/clean.rb +6 -4
- data/lib/git/commands/clone.rb +5 -4
- data/lib/git/commands/commit.rb +5 -4
- data/lib/git/commands/commit_tree.rb +5 -4
- data/lib/git/commands/config_option_syntax/add.rb +7 -4
- data/lib/git/commands/config_option_syntax/get.rb +9 -5
- data/lib/git/commands/config_option_syntax/get_all.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_color.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_color_bool.rb +7 -4
- data/lib/git/commands/config_option_syntax/get_regexp.rb +8 -4
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +8 -4
- data/lib/git/commands/config_option_syntax/list.rb +8 -4
- data/lib/git/commands/config_option_syntax/remove_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/rename_section.rb +7 -2
- data/lib/git/commands/config_option_syntax/replace_all.rb +7 -2
- data/lib/git/commands/config_option_syntax/set.rb +7 -2
- data/lib/git/commands/config_option_syntax/unset.rb +7 -4
- data/lib/git/commands/config_option_syntax/unset_all.rb +7 -2
- data/lib/git/commands/describe.rb +5 -4
- data/lib/git/commands/diff.rb +13 -12
- data/lib/git/commands/diff_files.rb +7 -6
- data/lib/git/commands/diff_index.rb +10 -7
- data/lib/git/commands/fetch.rb +6 -4
- data/lib/git/commands/fsck.rb +6 -4
- data/lib/git/commands/gc.rb +6 -4
- data/lib/git/commands/grep.rb +6 -5
- data/lib/git/commands/init.rb +6 -4
- data/lib/git/commands/log.rb +287 -285
- data/lib/git/commands/ls_files.rb +69 -65
- data/lib/git/commands/ls_remote.rb +62 -56
- data/lib/git/commands/ls_tree.rb +50 -46
- data/lib/git/commands/maintenance/register.rb +25 -23
- data/lib/git/commands/maintenance/run.rb +7 -2
- data/lib/git/commands/maintenance/start.rb +7 -2
- data/lib/git/commands/maintenance/stop.rb +7 -2
- data/lib/git/commands/maintenance/unregister.rb +7 -2
- data/lib/git/commands/merge/abort.rb +2 -2
- data/lib/git/commands/merge/continue.rb +2 -2
- data/lib/git/commands/merge/quit.rb +2 -2
- data/lib/git/commands/merge/start.rb +7 -2
- data/lib/git/commands/merge.rb +2 -2
- data/lib/git/commands/merge_base.rb +7 -2
- data/lib/git/commands/mv.rb +7 -2
- data/lib/git/commands/name_rev.rb +7 -2
- data/lib/git/commands/pull.rb +7 -2
- data/lib/git/commands/push.rb +7 -2
- data/lib/git/commands/read_tree.rb +7 -2
- data/lib/git/commands/remote/add.rb +7 -2
- data/lib/git/commands/remote/get_url.rb +4 -2
- data/lib/git/commands/remote/list.rb +4 -2
- data/lib/git/commands/remote/prune.rb +4 -2
- data/lib/git/commands/remote/remove.rb +4 -2
- data/lib/git/commands/remote/rename.rb +4 -2
- data/lib/git/commands/remote/set_branches.rb +9 -2
- data/lib/git/commands/remote/set_head.rb +12 -5
- data/lib/git/commands/remote/set_url.rb +9 -2
- data/lib/git/commands/remote/set_url_add.rb +11 -2
- data/lib/git/commands/remote/set_url_delete.rb +9 -2
- data/lib/git/commands/remote/show.rb +18 -12
- data/lib/git/commands/remote/update.rb +19 -12
- data/lib/git/commands/remote.rb +2 -2
- data/lib/git/commands/repack.rb +67 -63
- data/lib/git/commands/reset.rb +51 -44
- data/lib/git/commands/rev_parse.rb +135 -128
- data/lib/git/commands/revert/abort.rb +2 -2
- data/lib/git/commands/revert/continue.rb +7 -2
- data/lib/git/commands/revert/quit.rb +2 -2
- data/lib/git/commands/revert/skip.rb +2 -2
- data/lib/git/commands/revert/start.rb +7 -2
- data/lib/git/commands/revert.rb +2 -2
- data/lib/git/commands/rm.rb +35 -36
- data/lib/git/commands/show.rb +1 -1
- data/lib/git/commands/show_ref/exclude_existing.rb +3 -4
- data/lib/git/commands/show_ref/exists.rb +15 -13
- data/lib/git/commands/show_ref/list.rb +39 -35
- data/lib/git/commands/show_ref/verify.rb +29 -27
- data/lib/git/commands/show_ref.rb +4 -4
- data/lib/git/commands/stash/apply.rb +31 -25
- data/lib/git/commands/stash/branch.rb +10 -8
- data/lib/git/commands/stash/clear.rb +7 -5
- data/lib/git/commands/stash/create.rb +10 -8
- data/lib/git/commands/stash/drop.rb +15 -9
- data/lib/git/commands/stash/list.rb +9 -5
- data/lib/git/commands/stash/pop.rb +21 -12
- data/lib/git/commands/stash/push.rb +20 -11
- data/lib/git/commands/stash/show.rb +21 -12
- data/lib/git/commands/stash/store.rb +19 -10
- data/lib/git/commands/stash.rb +2 -2
- data/lib/git/commands/status.rb +7 -2
- data/lib/git/commands/symbolic_ref/delete.rb +18 -14
- data/lib/git/commands/symbolic_ref/read.rb +24 -20
- data/lib/git/commands/symbolic_ref/update.rb +20 -17
- data/lib/git/commands/symbolic_ref.rb +4 -4
- data/lib/git/commands/tag/create.rb +45 -42
- data/lib/git/commands/tag/delete.rb +5 -3
- data/lib/git/commands/tag/list.rb +47 -44
- data/lib/git/commands/tag/verify.rb +12 -12
- data/lib/git/commands/tag.rb +2 -2
- data/lib/git/commands/update_ref/batch.rb +6 -1
- data/lib/git/commands/update_ref/delete.rb +19 -21
- data/lib/git/commands/update_ref/update.rb +22 -25
- data/lib/git/commands/update_ref.rb +4 -4
- data/lib/git/commands/version.rb +14 -11
- data/lib/git/commands/worktree/add.rb +50 -51
- data/lib/git/commands/worktree/list.rb +17 -17
- data/lib/git/commands/worktree/lock.rb +12 -12
- data/lib/git/commands/worktree/move.rb +16 -16
- data/lib/git/commands/worktree/prune.rb +2 -2
- data/lib/git/commands/worktree/remove.rb +2 -2
- data/lib/git/commands/worktree/repair.rb +2 -2
- data/lib/git/commands/worktree/unlock.rb +2 -2
- data/lib/git/commands/write_tree.rb +2 -2
- data/lib/git/commands.rb +4 -3
- data/lib/git/config.rb +47 -1
- data/lib/git/configuring.rb +89 -15
- data/lib/git/detached_head_info.rb +4 -1
- data/lib/git/diff.rb +2 -5
- data/lib/git/diff_file_numstat_info.rb +3 -1
- data/lib/git/diff_file_patch_info.rb +3 -1
- data/lib/git/diff_file_raw_info.rb +3 -1
- data/lib/git/diff_info.rb +8 -15
- data/lib/git/diff_path_status.rb +16 -3
- data/lib/git/diff_result.rb +3 -1
- data/lib/git/diff_stats.rb +15 -0
- data/lib/git/dirstat_info.rb +24 -8
- data/lib/git/encoding_utils.rb +32 -1
- data/lib/git/errors.rb +19 -9
- data/lib/git/escaped_path.rb +55 -3
- data/lib/git/execution_context/repository.rb +15 -0
- data/lib/git/execution_context.rb +76 -74
- data/lib/git/file_ref.rb +6 -3
- data/lib/git/fsck_object.rb +8 -0
- data/lib/git/fsck_result.rb +26 -15
- data/lib/git/log.rb +152 -5
- data/lib/git/object.rb +284 -8
- data/lib/git/parsers/branch.rb +18 -0
- data/lib/git/parsers/cat_file.rb +2 -2
- data/lib/git/parsers/diff.rb +213 -5
- data/lib/git/parsers/fsck.rb +11 -0
- data/lib/git/parsers/ls_remote.rb +1 -1
- data/lib/git/parsers/stash.rb +51 -0
- data/lib/git/parsers/tag.rb +38 -0
- data/lib/git/remote.rb +34 -2
- data/lib/git/repository/branching.rb +23 -21
- data/lib/git/repository/committing.rb +46 -6
- data/lib/git/repository/context_helpers.rb +45 -16
- data/lib/git/repository/diffing.rb +32 -23
- data/lib/git/repository/factories.rb +153 -28
- data/lib/git/repository/inspecting.rb +1 -1
- data/lib/git/repository/logging.rb +169 -30
- data/lib/git/repository/maintenance.rb +1 -1
- data/lib/git/repository/merging.rb +3 -3
- data/lib/git/repository/object_operations.rb +108 -14
- data/lib/git/repository/remote_operations.rb +150 -171
- data/lib/git/repository/shared_private.rb +7 -5
- data/lib/git/repository/staging.rb +36 -12
- data/lib/git/repository/stashing.rb +16 -16
- data/lib/git/repository/status_operations.rb +1 -1
- data/lib/git/repository/worktree_operations.rb +1 -1
- data/lib/git/repository.rb +287 -6
- data/lib/git/stash.rb +16 -21
- data/lib/git/stash_info.rb +4 -4
- data/lib/git/stashes.rb +20 -26
- data/lib/git/status.rb +25 -13
- data/lib/git/tag_delete_failure.rb +3 -0
- data/lib/git/tag_delete_result.rb +6 -3
- data/lib/git/tag_info.rb +1 -0
- data/lib/git/url.rb +12 -5
- data/lib/git/version.rb +6 -4
- data/lib/git/version_constraint.rb +4 -0
- data/lib/git.rb +400 -314
- data/redesign/3_architecture_implementation.md +81 -30
- data/redesign/Phase 4 - Step A.md +6 -0
- data/redesign/Phase 4 - Step B.md +921 -0
- data/redesign/Phase 4 - Step C.md +833 -0
- data/redesign/c1a-public-api-scope.tsv +256 -0
- data/redesign/phase-4-step-b-test-audit.tsv +485 -0
- data/tasks/yard.rake +24 -17
- metadata +24 -58
- data/commitlint.test +0 -4
- data/lib/git/args_builder.rb +0 -103
- data/lib/git/command_line_result.rb +0 -8
- data/lib/git/deprecation.rb +0 -9
- data/lib/git/repository/configuring.rb +0 -351
- data/tasks/test.rake +0 -25
- /data/.github/{skills → skills-deprecated}/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -0
- /data/.github/{skills → skills-deprecated}/review-backward-compatibility/SKILL.md +0 -0
|
@@ -10,9 +10,13 @@ module Git
|
|
|
10
10
|
#
|
|
11
11
|
# Included by {Git::Repository}.
|
|
12
12
|
#
|
|
13
|
-
# @api
|
|
13
|
+
# @api private
|
|
14
14
|
#
|
|
15
15
|
module Logging
|
|
16
|
+
# Allowed option keys for {#full_log_commits}
|
|
17
|
+
#
|
|
18
|
+
# @return [Array<Symbol>] the supported option keys
|
|
19
|
+
#
|
|
16
20
|
FULL_LOG_COMMITS_ALLOWED_OPTS = %i[
|
|
17
21
|
count all cherry since until grep author between object path_limiter skip merges
|
|
18
22
|
].freeze
|
|
@@ -20,56 +24,59 @@ module Git
|
|
|
20
24
|
|
|
21
25
|
# Returns commits within the given revision range
|
|
22
26
|
#
|
|
23
|
-
# @
|
|
27
|
+
# @example Return commits from all refs
|
|
28
|
+
# repo.full_log_commits(all: true).first['sha']
|
|
29
|
+
# #=> "a1b2c3d4..."
|
|
24
30
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
31
|
+
# @example Return commits between two revisions
|
|
32
|
+
# repo.full_log_commits(between: ['v1.0.0', 'HEAD']).map { |c| c['sha'] }
|
|
33
|
+
# #=> ["d4e5f6...", "a1b2c3..."]
|
|
28
34
|
#
|
|
29
|
-
#
|
|
30
|
-
# repo.full_log_commits(between: ['v1.0.0', 'HEAD']).map { |c| c['sha'] }
|
|
31
|
-
# #=> ["d4e5f6...", "a1b2c3..."]
|
|
35
|
+
# @param opts [Hash] options for the log query
|
|
32
36
|
#
|
|
33
|
-
#
|
|
37
|
+
# @option opts [Integer, nil] :count (nil) maximum number of commits to return
|
|
34
38
|
#
|
|
35
|
-
#
|
|
39
|
+
# @option opts [Boolean, nil] :all (nil) include commits reachable from any ref
|
|
36
40
|
#
|
|
37
|
-
#
|
|
41
|
+
# @option opts [Boolean, nil] :cherry (nil) omit commits equivalent to
|
|
42
|
+
# cherry-picked commits
|
|
38
43
|
#
|
|
39
|
-
#
|
|
44
|
+
# @option opts [String] :since (nil) include commits newer than this date expression
|
|
40
45
|
#
|
|
41
|
-
#
|
|
46
|
+
# @option opts [String] :until (nil) include commits older than this date expression
|
|
42
47
|
#
|
|
43
|
-
#
|
|
48
|
+
# @option opts [String] :grep (nil) only include commits whose message matches
|
|
49
|
+
# this pattern
|
|
44
50
|
#
|
|
45
|
-
#
|
|
51
|
+
# @option opts [String] :author (nil) only include commits whose author matches
|
|
52
|
+
# this pattern
|
|
46
53
|
#
|
|
47
|
-
#
|
|
54
|
+
# @option opts [Array(String, String), nil] :between (nil) revision range as
|
|
55
|
+
# two commit-ish values
|
|
48
56
|
#
|
|
49
|
-
#
|
|
57
|
+
# When both `:between` and `:object` are provided, `:between` takes precedence.
|
|
50
58
|
#
|
|
51
|
-
#
|
|
59
|
+
# @option opts [String] :object (nil) single revision range expression for
|
|
60
|
+
# `git log`
|
|
52
61
|
#
|
|
53
|
-
#
|
|
62
|
+
# Ignored when `:between` is provided.
|
|
54
63
|
#
|
|
55
|
-
#
|
|
64
|
+
# @option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
|
|
65
|
+
# only include commits that impact files from the specified path(s)
|
|
56
66
|
#
|
|
57
|
-
#
|
|
58
|
-
# only include commits that impact files from the specified path(s)
|
|
67
|
+
# @option opts [Integer, nil] :skip (nil) skip this many commits before output
|
|
59
68
|
#
|
|
60
|
-
#
|
|
69
|
+
# @option opts [Boolean, nil] :merges (nil) include only merge commits
|
|
61
70
|
#
|
|
62
|
-
#
|
|
71
|
+
# @return [Array<Hash>] the parsed raw log output for each commit
|
|
63
72
|
#
|
|
64
|
-
#
|
|
73
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
65
74
|
#
|
|
66
|
-
#
|
|
75
|
+
# @raise [ArgumentError] if `:count` is not an Integer
|
|
67
76
|
#
|
|
68
|
-
#
|
|
77
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
69
78
|
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
# @see https://git-scm.com/docs/git-log git-log
|
|
79
|
+
# @see https://git-scm.com/docs/git-log git-log
|
|
73
80
|
#
|
|
74
81
|
def full_log_commits(opts = {})
|
|
75
82
|
SharedPrivate.assert_valid_opts!(FULL_LOG_COMMITS_ALLOWED_OPTS, **opts)
|
|
@@ -106,12 +113,35 @@ module Git
|
|
|
106
113
|
module Private
|
|
107
114
|
module_function
|
|
108
115
|
|
|
116
|
+
# Validates the :count log option
|
|
117
|
+
#
|
|
118
|
+
# @param opts [Hash] the log options
|
|
119
|
+
#
|
|
120
|
+
# @option opts [Integer, nil] :count (nil) the maximum number of commits to
|
|
121
|
+
# return
|
|
122
|
+
#
|
|
123
|
+
# @return [void]
|
|
124
|
+
#
|
|
125
|
+
# @raise [ArgumentError] if the log count option is not an Integer
|
|
126
|
+
#
|
|
109
127
|
def validate_log_count_option!(opts)
|
|
110
128
|
return if opts[:count].nil? || opts[:count].is_a?(Integer)
|
|
111
129
|
|
|
112
130
|
raise ArgumentError, "The log count option must be an Integer but was #{opts[:count].inspect}"
|
|
113
131
|
end
|
|
114
132
|
|
|
133
|
+
# Validates the :between log option
|
|
134
|
+
#
|
|
135
|
+
# @param opts [Hash] the log options
|
|
136
|
+
#
|
|
137
|
+
# @option opts [Array(String, String), nil] :between (nil) the two-commit
|
|
138
|
+
# revision range to validate
|
|
139
|
+
#
|
|
140
|
+
# @return [void]
|
|
141
|
+
#
|
|
142
|
+
# @raise [ArgumentError] if the :between option is not an Array with exactly
|
|
143
|
+
# two non-nil values
|
|
144
|
+
#
|
|
115
145
|
def validate_log_between_option!(opts)
|
|
116
146
|
between = opts[:between]
|
|
117
147
|
return if between.nil?
|
|
@@ -121,6 +151,17 @@ module Git
|
|
|
121
151
|
"The log between option must be an Array with exactly two non-nil values but was #{between.inspect}"
|
|
122
152
|
end
|
|
123
153
|
|
|
154
|
+
# Builds positional revision arguments for `git log`
|
|
155
|
+
#
|
|
156
|
+
# @param opts [Hash] the log options
|
|
157
|
+
#
|
|
158
|
+
# @option opts [Array(String, String), nil] :between (nil) a two-revision
|
|
159
|
+
# range where index `0` is the start and index `1` is the end
|
|
160
|
+
#
|
|
161
|
+
# @option opts [String, nil] :object (nil) a single revision range expression
|
|
162
|
+
#
|
|
163
|
+
# @return [Array<String>] zero or one positional revision arguments
|
|
164
|
+
#
|
|
124
165
|
def log_revision_range_args(opts)
|
|
125
166
|
if opts[:between]
|
|
126
167
|
["#{opts[:between][0]}..#{opts[:between][1]}"]
|
|
@@ -131,6 +172,40 @@ module Git
|
|
|
131
172
|
end
|
|
132
173
|
end
|
|
133
174
|
|
|
175
|
+
# Builds keyword options passed to {Git::Commands::Log#call}
|
|
176
|
+
#
|
|
177
|
+
# @param opts [Hash] the log options
|
|
178
|
+
#
|
|
179
|
+
# @param extra [Hash] additional keyword options merged into the call options
|
|
180
|
+
#
|
|
181
|
+
# @option opts [Boolean, nil] :all (nil) include commits reachable from any ref
|
|
182
|
+
#
|
|
183
|
+
# @option opts [Boolean, nil] :cherry (nil) omit commits equivalent to
|
|
184
|
+
# cherry-picked commits
|
|
185
|
+
#
|
|
186
|
+
# @option opts [String, nil] :since (nil) include commits newer than this date
|
|
187
|
+
# expression
|
|
188
|
+
#
|
|
189
|
+
# @option opts [String, nil] :until (nil) include commits older than this date
|
|
190
|
+
# expression
|
|
191
|
+
#
|
|
192
|
+
# @option opts [String, nil] :grep (nil) only include commits whose message
|
|
193
|
+
# matches this pattern
|
|
194
|
+
#
|
|
195
|
+
# @option opts [String, nil] :author (nil) only include commits whose author
|
|
196
|
+
# matches this pattern
|
|
197
|
+
#
|
|
198
|
+
# @option opts [Integer, nil] :count (nil) maximum number of commits to return
|
|
199
|
+
#
|
|
200
|
+
# @option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
|
|
201
|
+
# only include commits that impact files from the specified path(s)
|
|
202
|
+
#
|
|
203
|
+
# @option extra [Integer, nil] :skip (nil) skip this many commits before output
|
|
204
|
+
#
|
|
205
|
+
# @option extra [Boolean, nil] :merges (nil) include only merge commits
|
|
206
|
+
#
|
|
207
|
+
# @return [Hash] keyword options for {Git::Commands::Log#call}
|
|
208
|
+
#
|
|
134
209
|
def log_base_call_options(opts, extra = {})
|
|
135
210
|
{
|
|
136
211
|
all: opts[:all],
|
|
@@ -144,6 +219,18 @@ module Git
|
|
|
144
219
|
}.merge(extra).compact
|
|
145
220
|
end
|
|
146
221
|
|
|
222
|
+
# Executes git log and parses the raw output
|
|
223
|
+
#
|
|
224
|
+
# @param execution_context [Git::ExecutionContext] the execution context
|
|
225
|
+
#
|
|
226
|
+
# @param revision_range_args [Array<String>] positional revision range arguments
|
|
227
|
+
#
|
|
228
|
+
# @param call_opts [Hash] keyword options for {Git::Commands::Log#call}
|
|
229
|
+
#
|
|
230
|
+
# @return [Array<Hash>] parsed commits from the command output
|
|
231
|
+
#
|
|
232
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
233
|
+
#
|
|
147
234
|
def run_log_command(execution_context, revision_range_args, call_opts)
|
|
148
235
|
log_or_empty_on_unborn do
|
|
149
236
|
result = Git::Commands::Log.new(execution_context).call(
|
|
@@ -156,6 +243,16 @@ module Git
|
|
|
156
243
|
end
|
|
157
244
|
end
|
|
158
245
|
|
|
246
|
+
# Returns an empty result when the repository has no commits yet
|
|
247
|
+
#
|
|
248
|
+
# @return [Array<Hash>] parsed commits or an empty array for unborn repositories
|
|
249
|
+
#
|
|
250
|
+
# @raise [Git::FailedError] if git fails for a reason other than unborn history
|
|
251
|
+
#
|
|
252
|
+
# @yield [] runs the wrapped log command
|
|
253
|
+
#
|
|
254
|
+
# @yieldreturn [Array<Hash>] the parsed commits from the wrapped command
|
|
255
|
+
#
|
|
159
256
|
def log_or_empty_on_unborn
|
|
160
257
|
yield
|
|
161
258
|
rescue Git::FailedError => e
|
|
@@ -170,6 +267,12 @@ module Git
|
|
|
170
267
|
# @api private
|
|
171
268
|
#
|
|
172
269
|
class RawLogParser
|
|
270
|
+
# Initializes a parser for raw git log output lines
|
|
271
|
+
#
|
|
272
|
+
# @param lines [Array<String>] raw output lines from `git log --pretty=raw`
|
|
273
|
+
#
|
|
274
|
+
# @return [void]
|
|
275
|
+
#
|
|
173
276
|
def initialize(lines)
|
|
174
277
|
@lines = lines
|
|
175
278
|
@commits = []
|
|
@@ -190,6 +293,12 @@ module Git
|
|
|
190
293
|
|
|
191
294
|
private
|
|
192
295
|
|
|
296
|
+
# Routes a raw line to message or metadata parsing
|
|
297
|
+
#
|
|
298
|
+
# @param line [String] the current raw log output line
|
|
299
|
+
#
|
|
300
|
+
# @return [void]
|
|
301
|
+
#
|
|
193
302
|
def process_line(line)
|
|
194
303
|
if line.empty?
|
|
195
304
|
@in_message = !@in_message
|
|
@@ -201,10 +310,22 @@ module Git
|
|
|
201
310
|
@in_message ? process_message_line(line) : process_metadata_line(line)
|
|
202
311
|
end
|
|
203
312
|
|
|
313
|
+
# Appends a commit message line to the current commit buffer
|
|
314
|
+
#
|
|
315
|
+
# @param line [String] an indented message line from raw output
|
|
316
|
+
#
|
|
317
|
+
# @return [void]
|
|
318
|
+
#
|
|
204
319
|
def process_message_line(line)
|
|
205
320
|
@current_commit['message'] << "#{line[4..]}\n"
|
|
206
321
|
end
|
|
207
322
|
|
|
323
|
+
# Parses metadata lines and multi-line metadata continuations
|
|
324
|
+
#
|
|
325
|
+
# @param line [String] a metadata line from raw output
|
|
326
|
+
#
|
|
327
|
+
# @return [void]
|
|
328
|
+
#
|
|
208
329
|
def process_metadata_line(line)
|
|
209
330
|
if line.start_with?(' ') && @last_metadata_key
|
|
210
331
|
@current_commit[@last_metadata_key] << "\n#{line[1..]}"
|
|
@@ -217,6 +338,14 @@ module Git
|
|
|
217
338
|
dispatch_metadata_key(key, value)
|
|
218
339
|
end
|
|
219
340
|
|
|
341
|
+
# Applies a metadata key/value pair to the current commit
|
|
342
|
+
#
|
|
343
|
+
# @param key [String] the metadata key from the raw log line
|
|
344
|
+
#
|
|
345
|
+
# @param value [String] the parsed metadata value
|
|
346
|
+
#
|
|
347
|
+
# @return [void]
|
|
348
|
+
#
|
|
220
349
|
def dispatch_metadata_key(key, value)
|
|
221
350
|
case key
|
|
222
351
|
when 'commit'
|
|
@@ -229,12 +358,22 @@ module Git
|
|
|
229
358
|
end
|
|
230
359
|
end
|
|
231
360
|
|
|
361
|
+
# Starts a new commit record in the parser state
|
|
362
|
+
#
|
|
363
|
+
# @param sha [String] the commit SHA for the new record
|
|
364
|
+
#
|
|
365
|
+
# @return [void]
|
|
366
|
+
#
|
|
232
367
|
def start_new_commit(sha)
|
|
233
368
|
finalize_commit
|
|
234
369
|
@current_commit = { 'sha' => sha, 'message' => +'', 'parent' => [] }
|
|
235
370
|
@last_metadata_key = nil
|
|
236
371
|
end
|
|
237
372
|
|
|
373
|
+
# Appends the current commit to the parsed results when present
|
|
374
|
+
#
|
|
375
|
+
# @return [void]
|
|
376
|
+
#
|
|
238
377
|
def finalize_commit
|
|
239
378
|
@commits << @current_commit if @current_commit
|
|
240
379
|
end
|
|
@@ -15,7 +15,7 @@ module Git
|
|
|
15
15
|
#
|
|
16
16
|
# Included by {Git::Repository}.
|
|
17
17
|
#
|
|
18
|
-
# @api
|
|
18
|
+
# @api private
|
|
19
19
|
#
|
|
20
20
|
module Merging
|
|
21
21
|
# Option keys accepted by {#merge}
|
|
@@ -333,14 +333,14 @@ module Git
|
|
|
333
333
|
#
|
|
334
334
|
# @param stage [Integer] git stage index (2 = ours, 3 = theirs)
|
|
335
335
|
#
|
|
336
|
+
# @return [void]
|
|
337
|
+
#
|
|
336
338
|
# @yield [f] yields the open Tempfile containing the staged content
|
|
337
339
|
#
|
|
338
340
|
# @yieldparam f [Tempfile] open IO object for the staged content
|
|
339
341
|
#
|
|
340
342
|
# @yieldreturn [void]
|
|
341
343
|
#
|
|
342
|
-
# @return [void]
|
|
343
|
-
#
|
|
344
344
|
# @api private
|
|
345
345
|
#
|
|
346
346
|
def write_staged_file(execution_context, file_path, stage)
|
|
@@ -27,7 +27,7 @@ module Git
|
|
|
27
27
|
#
|
|
28
28
|
# Included by {Git::Repository}.
|
|
29
29
|
#
|
|
30
|
-
# @api
|
|
30
|
+
# @api private
|
|
31
31
|
#
|
|
32
32
|
module ObjectOperations # rubocop:disable Metrics/ModuleLength
|
|
33
33
|
# Returns the raw content of a git object, or streams it into a tempfile
|
|
@@ -854,7 +854,7 @@ module Git
|
|
|
854
854
|
#
|
|
855
855
|
# @param name [String] the name of the tag to delete
|
|
856
856
|
#
|
|
857
|
-
# @param delete_options [{
|
|
857
|
+
# @param delete_options [Hash{Symbol => Boolean}] deletion options;
|
|
858
858
|
# only `:d` or `:delete` (set to `true`) is accepted — no other keys
|
|
859
859
|
# and no `target` argument may be combined with this form
|
|
860
860
|
#
|
|
@@ -885,8 +885,6 @@ module Git
|
|
|
885
885
|
tag(name)
|
|
886
886
|
end
|
|
887
887
|
|
|
888
|
-
# @deprecated Use {#tag_add} instead.
|
|
889
|
-
#
|
|
890
888
|
# @overload add_tag(name, options = {})
|
|
891
889
|
#
|
|
892
890
|
# @param name [String] the name of the tag to create
|
|
@@ -912,12 +910,14 @@ module Git
|
|
|
912
910
|
#
|
|
913
911
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
914
912
|
#
|
|
915
|
-
|
|
913
|
+
# @deprecated Use {#tag_add} instead
|
|
914
|
+
#
|
|
915
|
+
def add_tag(name, *)
|
|
916
916
|
Git::Deprecation.warn(
|
|
917
917
|
'Git::Repository#add_tag is deprecated and will be removed in v6.0.0. ' \
|
|
918
918
|
'Use Git::Repository#tag_add instead.'
|
|
919
919
|
)
|
|
920
|
-
tag_add(name, *
|
|
920
|
+
tag_add(name, *)
|
|
921
921
|
end
|
|
922
922
|
|
|
923
923
|
# Delete a tag
|
|
@@ -938,14 +938,14 @@ module Git
|
|
|
938
938
|
result.stdout
|
|
939
939
|
end
|
|
940
940
|
|
|
941
|
-
# @deprecated Use {#tag_delete} instead.
|
|
942
|
-
#
|
|
943
941
|
# @param name [String] the name of the tag to delete
|
|
944
942
|
#
|
|
945
943
|
# @return [String] git's stdout from the delete
|
|
946
944
|
#
|
|
947
945
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
948
946
|
#
|
|
947
|
+
# @deprecated Use {#tag_delete} instead
|
|
948
|
+
#
|
|
949
949
|
def delete_tag(name)
|
|
950
950
|
Git::Deprecation.warn(
|
|
951
951
|
'Git::Repository#delete_tag is deprecated and will be removed in v6.0.0. ' \
|
|
@@ -966,6 +966,26 @@ module Git
|
|
|
966
966
|
#
|
|
967
967
|
# @param opts [Hash] the tag-creation options
|
|
968
968
|
#
|
|
969
|
+
# @option opts [Boolean, nil] :annotate request an annotated tag
|
|
970
|
+
#
|
|
971
|
+
# @option opts [Boolean, nil] :a alias for `:annotate`
|
|
972
|
+
#
|
|
973
|
+
# @option opts [Boolean, nil] :sign request a signed tag
|
|
974
|
+
#
|
|
975
|
+
# @option opts [Boolean, nil] :s alias for `:sign`
|
|
976
|
+
#
|
|
977
|
+
# @option opts [String] :local_user key id used when signing
|
|
978
|
+
#
|
|
979
|
+
# @option opts [String] :u alias for `:local_user`
|
|
980
|
+
#
|
|
981
|
+
# @option opts [String] :message tag message text
|
|
982
|
+
#
|
|
983
|
+
# @option opts [String] :m alias for `:message`
|
|
984
|
+
#
|
|
985
|
+
# @option opts [String] :file path to a tag message file
|
|
986
|
+
#
|
|
987
|
+
# @option opts [String] :F alias for `:file`
|
|
988
|
+
#
|
|
969
989
|
# @return [void]
|
|
970
990
|
#
|
|
971
991
|
# @raise [ArgumentError] when an annotated or signed tag is requested
|
|
@@ -986,10 +1006,18 @@ module Git
|
|
|
986
1006
|
# ArgumentError if a target or incompatible options are also supplied.
|
|
987
1007
|
#
|
|
988
1008
|
# @param facade [ObjectOperations] the calling facade instance
|
|
1009
|
+
#
|
|
989
1010
|
# @param name [String] tag name
|
|
1011
|
+
#
|
|
990
1012
|
# @param target [String, nil] target argument (must be nil)
|
|
1013
|
+
#
|
|
991
1014
|
# @param opts [Hash] options hash (must contain only :d/:delete)
|
|
992
1015
|
#
|
|
1016
|
+
# @option opts [Boolean] :d (true) request deletion in the deprecated
|
|
1017
|
+
# `tag_add` form
|
|
1018
|
+
#
|
|
1019
|
+
# @option opts [Boolean] :delete (true) alias for `:d`
|
|
1020
|
+
#
|
|
993
1021
|
# @return [String] stdout from tag_delete
|
|
994
1022
|
#
|
|
995
1023
|
# @api private
|
|
@@ -1007,6 +1035,20 @@ module Git
|
|
|
1007
1035
|
facade.tag_delete(name)
|
|
1008
1036
|
end
|
|
1009
1037
|
|
|
1038
|
+
# Returns the direct SHA for a tag reference
|
|
1039
|
+
#
|
|
1040
|
+
# Returns the hash from `refs/tags/<name>` only. Returns an empty string
|
|
1041
|
+
# when the ref does not exist.
|
|
1042
|
+
#
|
|
1043
|
+
# @param execution_context [Git::ExecutionContext] for running
|
|
1044
|
+
# `git show-ref`
|
|
1045
|
+
#
|
|
1046
|
+
# @param tag_name [String] tag name without the `refs/tags/` prefix
|
|
1047
|
+
#
|
|
1048
|
+
# @return [String] direct ref SHA or an empty string when missing
|
|
1049
|
+
#
|
|
1050
|
+
# @api private
|
|
1051
|
+
#
|
|
1010
1052
|
def show_ref_tag_sha(execution_context, tag_name)
|
|
1011
1053
|
ref = "refs/tags/#{tag_name}"
|
|
1012
1054
|
result = Git::Commands::ShowRef::List.new(execution_context).call(ref)
|
|
@@ -1016,6 +1058,13 @@ module Git
|
|
|
1016
1058
|
line ? line.split[0] : ''
|
|
1017
1059
|
end
|
|
1018
1060
|
|
|
1061
|
+
# Parses the result of a git grep command
|
|
1062
|
+
#
|
|
1063
|
+
# @param result [Git::CommandLine::Result] the result of a git grep command
|
|
1064
|
+
#
|
|
1065
|
+
# @return [Hash<String, Array<Array(Integer, String)>>] hash mapping "treeish:filename"
|
|
1066
|
+
# keys to arrays of [line_number, text] pairs
|
|
1067
|
+
#
|
|
1019
1068
|
def parse_grep_result(result)
|
|
1020
1069
|
exitstatus = result.status.exitstatus
|
|
1021
1070
|
return {} if exitstatus == 1 && result.stderr.empty?
|
|
@@ -1051,11 +1100,27 @@ module Git
|
|
|
1051
1100
|
# are determined from `opts` via {#parse_archive_format_options}.
|
|
1052
1101
|
#
|
|
1053
1102
|
# @param execution_context [Git::ExecutionContext] for the git command
|
|
1103
|
+
#
|
|
1054
1104
|
# @param treeish [String] tree-ish passed to `git archive`
|
|
1055
|
-
#
|
|
1105
|
+
#
|
|
1056
1106
|
# @param dest_dir [String] directory for the staging temp file; use
|
|
1057
1107
|
# {#staging_dir_for} to select the optimal directory for the destination
|
|
1058
1108
|
#
|
|
1109
|
+
# @param opts [Hash] caller-supplied options (read-only)
|
|
1110
|
+
#
|
|
1111
|
+
# @option opts [String] :format ('zip') archive format (`'tar'`, `'zip'`,
|
|
1112
|
+
# or `'tgz'`)
|
|
1113
|
+
#
|
|
1114
|
+
# @option opts [Boolean, nil] :add_gzip (nil) apply gzip post-processing
|
|
1115
|
+
# to the generated archive
|
|
1116
|
+
#
|
|
1117
|
+
# @option opts [String] :prefix (nil) prefix for entries in the archive
|
|
1118
|
+
#
|
|
1119
|
+
# @option opts [String] :path (nil) path within `treeish` to archive
|
|
1120
|
+
#
|
|
1121
|
+
# @option opts [String] :remote (nil) remote repository from which to
|
|
1122
|
+
# retrieve the archive
|
|
1123
|
+
#
|
|
1059
1124
|
# @return [String] path to the populated temporary file
|
|
1060
1125
|
#
|
|
1061
1126
|
# @api private
|
|
@@ -1078,12 +1143,23 @@ module Git
|
|
|
1078
1143
|
# method returns and after the caller stores only the path string.
|
|
1079
1144
|
#
|
|
1080
1145
|
# @param execution_context [Git::ExecutionContext] for the git command
|
|
1146
|
+
#
|
|
1081
1147
|
# @param treeish [String] tree-ish passed to `git archive`
|
|
1082
|
-
#
|
|
1083
|
-
# :remote, and :path)
|
|
1148
|
+
#
|
|
1084
1149
|
# @param format [String] archive format string (e.g. `'zip'` or `'tar'`)
|
|
1150
|
+
#
|
|
1085
1151
|
# @param dest_dir [String] directory in which to create the temp file
|
|
1086
1152
|
#
|
|
1153
|
+
# @param opts [Hash] caller-supplied options (read-only; used for :prefix,
|
|
1154
|
+
# :remote, and :path)
|
|
1155
|
+
#
|
|
1156
|
+
# @option opts [String] :prefix (nil) prefix for entries in the archive
|
|
1157
|
+
#
|
|
1158
|
+
# @option opts [String] :path (nil) path within `treeish` to archive
|
|
1159
|
+
#
|
|
1160
|
+
# @option opts [String] :remote (nil) remote repository from which to
|
|
1161
|
+
# retrieve the archive
|
|
1162
|
+
#
|
|
1087
1163
|
# @return [File] the closed file containing the archive
|
|
1088
1164
|
#
|
|
1089
1165
|
# @api private
|
|
@@ -1102,13 +1178,24 @@ module Git
|
|
|
1102
1178
|
# Invoke `git archive` and stream output into `tmp_file`
|
|
1103
1179
|
#
|
|
1104
1180
|
# @param execution_context [Git::ExecutionContext] for the git command
|
|
1181
|
+
#
|
|
1105
1182
|
# @param treeish [String] tree-ish passed to `git archive`
|
|
1106
|
-
#
|
|
1107
|
-
# :remote, and :path)
|
|
1183
|
+
#
|
|
1108
1184
|
# @param format [String] archive format to pass to `git archive --format`
|
|
1185
|
+
#
|
|
1109
1186
|
# @param tmp_file [File] open, binary-mode IO to write archive data to
|
|
1110
1187
|
#
|
|
1111
|
-
# @
|
|
1188
|
+
# @param opts [Hash] caller-supplied options (read-only; used for :prefix,
|
|
1189
|
+
# :remote, and :path)
|
|
1190
|
+
#
|
|
1191
|
+
# @option opts [String] :prefix (nil) prefix for entries in the archive
|
|
1192
|
+
#
|
|
1193
|
+
# @option opts [String] :path (nil) path within `treeish` to archive
|
|
1194
|
+
#
|
|
1195
|
+
# @option opts [String] :remote (nil) remote repository from which to
|
|
1196
|
+
# retrieve the archive
|
|
1197
|
+
#
|
|
1198
|
+
# @return [Git::CommandLine::Result] the result of the git command
|
|
1112
1199
|
#
|
|
1113
1200
|
# @api private
|
|
1114
1201
|
#
|
|
@@ -1134,6 +1221,7 @@ module Git
|
|
|
1134
1221
|
# staging file rather than writing through the link to its target.
|
|
1135
1222
|
#
|
|
1136
1223
|
# @param src [String] staging file path to rename; removed on success
|
|
1224
|
+
#
|
|
1137
1225
|
# @param dest [String] destination file path
|
|
1138
1226
|
#
|
|
1139
1227
|
# @return [void]
|
|
@@ -1157,6 +1245,12 @@ module Git
|
|
|
1157
1245
|
#
|
|
1158
1246
|
# @param opts [Hash] caller-supplied options hash (read-only)
|
|
1159
1247
|
#
|
|
1248
|
+
# @option opts [String] :format ('zip') archive format (`'tar'`, `'zip'`,
|
|
1249
|
+
# or `'tgz'`)
|
|
1250
|
+
#
|
|
1251
|
+
# @option opts [Boolean, nil] :add_gzip (nil) apply gzip post-processing
|
|
1252
|
+
# after archive generation
|
|
1253
|
+
#
|
|
1160
1254
|
# @return [Array(String, Boolean)] a two-element array `[format, gzip]`
|
|
1161
1255
|
#
|
|
1162
1256
|
# `format` is the string to pass to `git archive --format`; `gzip` is
|