git 5.0.0.beta.1 → 5.0.0.beta.2
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/.github/copilot-instructions.md +6 -0
- data/.github/prompts/iteratively-address-copilot-reviews.prompt.md +188 -0
- data/.github/skills/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +22 -0
- data/.github/skills/extract-facade-from-base-lib/SKILL.md +28 -14
- data/.github/skills/facade-implementation/SKILL.md +14 -0
- data/.github/skills/facade-test-conventions/SKILL.md +14 -0
- data/.rubocop.yml +5 -0
- data/README.md +51 -11
- data/UPGRADING.md +141 -0
- data/git.gemspec +5 -0
- data/lib/git/branch.rb +7 -18
- data/lib/git/branches.rb +2 -10
- data/lib/git/command_line/base.rb +10 -0
- data/lib/git/command_line/capturing.rb +5 -3
- data/lib/git/command_line/streaming.rb +5 -3
- data/lib/git/command_line.rb +3 -3
- data/lib/git/commands/base.rb +7 -6
- data/lib/git/commands/cat_file/batch.rb +6 -1
- data/lib/git/commands/cat_file/raw.rb +7 -1
- data/lib/git/commands/config_option_syntax/get_urlmatch.rb +5 -0
- data/lib/git/commands/show_ref/exclude_existing.rb +1 -1
- data/lib/git/commands/update_ref/batch.rb +1 -1
- data/lib/git/commands/version.rb +5 -0
- data/lib/git/commands.rb +5 -7
- data/lib/git/config.rb +17 -0
- data/lib/git/config_entry_info.rb +106 -0
- data/lib/git/configuring.rb +665 -0
- data/lib/git/deprecation.rb +9 -0
- data/lib/git/diff.rb +4 -8
- data/lib/git/diff_path_status.rb +2 -13
- data/lib/git/diff_stats.rb +1 -9
- data/lib/git/execution_context/global.rb +3 -28
- data/lib/git/execution_context/repository.rb +30 -41
- data/lib/git/execution_context.rb +43 -24
- data/lib/git/log.rb +3 -9
- data/lib/git/object.rb +14 -21
- data/lib/git/parsers/config_entry.rb +110 -0
- data/lib/git/parsers/ls_remote.rb +79 -0
- data/lib/git/remote.rb +7 -20
- data/lib/git/repository/branching.rb +183 -12
- data/lib/git/repository/committing.rb +64 -68
- data/lib/git/repository/configuring.rb +208 -13
- data/lib/git/repository/context_helpers.rb +264 -0
- data/lib/git/repository/factories.rb +682 -0
- data/lib/git/repository/inspecting.rb +99 -0
- data/lib/git/repository/maintenance.rb +65 -0
- data/lib/git/repository/merging.rb +63 -1
- data/lib/git/repository/object_operations.rb +133 -35
- data/lib/git/repository/path_resolver.rb +1 -1
- data/lib/git/repository/remote_operations.rb +166 -21
- data/lib/git/repository/staging.rb +187 -23
- data/lib/git/repository/stashing.rb +39 -3
- data/lib/git/repository/status_operations.rb +21 -0
- data/lib/git/repository.rb +68 -129
- data/lib/git/stash.rb +2 -9
- data/lib/git/stashes.rb +2 -7
- data/lib/git/status.rb +8 -17
- data/lib/git/version.rb +2 -2
- data/lib/git/worktree.rb +2 -15
- data/lib/git/worktrees.rb +2 -15
- data/lib/git.rb +180 -77
- data/redesign/3_architecture_implementation.md +148 -111
- data/redesign/Phase 4 - Step A.md +360 -0
- data/redesign/beta_release.md +107 -0
- data/redesign/c1c2_audit.md +566 -0
- data/redesign/c1c2_bucket6_lib_orphans.md +626 -0
- data/redesign/config_design.rb +501 -0
- metadata +19 -5
- data/lib/git/base.rb +0 -1204
- data/lib/git/lib.rb +0 -2855
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'git/commands/describe'
|
|
3
4
|
require 'git/commands/fsck'
|
|
4
5
|
require 'git/commands/show'
|
|
5
6
|
require 'git/parsers/fsck'
|
|
@@ -16,6 +17,97 @@ module Git
|
|
|
16
17
|
# @api public
|
|
17
18
|
#
|
|
18
19
|
module Inspecting
|
|
20
|
+
# Give a human-readable name to a commit based on the most recent reachable tag
|
|
21
|
+
#
|
|
22
|
+
# Runs `git describe` to find the nearest tag reachable from `committish` and
|
|
23
|
+
# formats a version string. When the tag points directly at the commit, only the
|
|
24
|
+
# tag name is shown. Otherwise, the tag name is suffixed with the number of
|
|
25
|
+
# additional commits and the abbreviated commit SHA (e.g. `v1.0.0-3-gabcdef1`).
|
|
26
|
+
#
|
|
27
|
+
# @example Describe HEAD
|
|
28
|
+
# repo.describe #=> "v1.0.0"
|
|
29
|
+
#
|
|
30
|
+
# @example Describe a specific commit
|
|
31
|
+
# repo.describe('abc123') #=> "v1.0.0-3-gabcdef1"
|
|
32
|
+
#
|
|
33
|
+
# @example Describe using any tag (not just annotated tags)
|
|
34
|
+
# repo.describe(nil, tags: true) #=> "v1.0.0-lightweight"
|
|
35
|
+
#
|
|
36
|
+
# @example Require an exact tag match
|
|
37
|
+
# repo.describe(nil, exact_match: true)
|
|
38
|
+
#
|
|
39
|
+
# @example Use the legacy hyphenated key (still accepted)
|
|
40
|
+
# repo.describe(nil, :'exact-match' => true)
|
|
41
|
+
#
|
|
42
|
+
# @param committish [String, nil] the commit-ish to describe; defaults to HEAD
|
|
43
|
+
# when `nil`
|
|
44
|
+
#
|
|
45
|
+
# @param opts [Hash] options forwarded to `git describe`
|
|
46
|
+
#
|
|
47
|
+
# @option opts [Boolean, nil] :all (nil) use any ref in `refs/`, not just tags
|
|
48
|
+
#
|
|
49
|
+
# @option opts [Boolean, nil] :tags (nil) use lightweight tags as well as
|
|
50
|
+
# annotated ones
|
|
51
|
+
#
|
|
52
|
+
# @option opts [Boolean, nil] :contains (nil) describe the tag that contains the
|
|
53
|
+
# commit, rather than the nearest reachable one
|
|
54
|
+
#
|
|
55
|
+
# @option opts [Boolean, String, nil] :abbrev (nil) number of hex digits for the
|
|
56
|
+
# abbreviated object name; `true` uses git's default length
|
|
57
|
+
#
|
|
58
|
+
# @option opts [Boolean, String, nil] :dirty (nil) append a dirty-state mark to
|
|
59
|
+
# the description; `true` appends `-dirty`, a String appends that string
|
|
60
|
+
#
|
|
61
|
+
# @option opts [Boolean, String, nil] :broken (nil) like `:dirty` but treats
|
|
62
|
+
# broken repository links as dirty
|
|
63
|
+
#
|
|
64
|
+
# @option opts [Integer, String, nil] :candidates (nil) number of candidate tags
|
|
65
|
+
# to consider; increasing above 10 may yield a more accurate result
|
|
66
|
+
#
|
|
67
|
+
# @option opts [Boolean, nil] :exact_match (nil) only succeed when the commit is
|
|
68
|
+
# pointed to by a tag directly (no suffix)
|
|
69
|
+
#
|
|
70
|
+
# The legacy hyphenated key `:"exact-match"` is also accepted and is
|
|
71
|
+
# automatically translated to `:exact_match`.
|
|
72
|
+
#
|
|
73
|
+
# @option opts [Boolean, nil] :debug (nil) verbosely display the search strategy
|
|
74
|
+
#
|
|
75
|
+
# @option opts [Boolean, nil] :long (nil) always output the long format even when
|
|
76
|
+
# the commit matches a tag exactly
|
|
77
|
+
#
|
|
78
|
+
# @option opts [String, Array<String>, nil] :match (nil) only consider tags
|
|
79
|
+
# matching the given `glob(7)` pattern; pass an array for multiple patterns
|
|
80
|
+
#
|
|
81
|
+
# @option opts [String, Array<String>, nil] :exclude (nil) do not consider tags
|
|
82
|
+
# matching the given `glob(7)` pattern; pass an array for multiple patterns
|
|
83
|
+
#
|
|
84
|
+
# @option opts [Boolean, nil] :always (nil) show the abbreviated commit SHA as
|
|
85
|
+
# fallback when the commit cannot be described
|
|
86
|
+
#
|
|
87
|
+
# @option opts [Boolean, nil] :first_parent (nil) follow only the first parent of
|
|
88
|
+
# merge commits when searching for the nearest tag
|
|
89
|
+
#
|
|
90
|
+
# @return [String] the human-readable description of the commit, with trailing
|
|
91
|
+
# newlines preserved
|
|
92
|
+
#
|
|
93
|
+
# @raise [Git::FailedError] when git exits with a non-zero exit status
|
|
94
|
+
#
|
|
95
|
+
# @raise [ArgumentError] when `committish` looks like a command-line flag (starts
|
|
96
|
+
# with `-`), or when `opts` contains any key not in the documented option list
|
|
97
|
+
#
|
|
98
|
+
def describe(committish = nil, opts = {})
|
|
99
|
+
raise ArgumentError, "Invalid commit-ish object: '#{committish}'" if committish&.start_with?('-')
|
|
100
|
+
|
|
101
|
+
opts = opts.dup
|
|
102
|
+
if opts.key?(:'exact-match')
|
|
103
|
+
opts[:exact_match] ||= opts[:'exact-match']
|
|
104
|
+
opts.delete(:'exact-match')
|
|
105
|
+
end
|
|
106
|
+
SharedPrivate.assert_valid_opts!(DESCRIBE_ALLOWED_OPTS, **opts)
|
|
107
|
+
commit_ishes = Array(committish).compact
|
|
108
|
+
Git::Commands::Describe.new(@execution_context).call(*commit_ishes, **opts).stdout
|
|
109
|
+
end
|
|
110
|
+
|
|
19
111
|
# Show a single git object (a commit, tag, tree, or blob)
|
|
20
112
|
#
|
|
21
113
|
# @example Show the HEAD commit
|
|
@@ -49,6 +141,13 @@ module Git
|
|
|
49
141
|
Git::Commands::Show.new(@execution_context).call(*[object].compact).stdout
|
|
50
142
|
end
|
|
51
143
|
|
|
144
|
+
# Option keys accepted by {#describe}
|
|
145
|
+
DESCRIBE_ALLOWED_OPTS = %i[
|
|
146
|
+
all tags contains abbrev dirty broken candidates
|
|
147
|
+
exact_match debug long match exclude always first_parent
|
|
148
|
+
].freeze
|
|
149
|
+
private_constant :DESCRIBE_ALLOWED_OPTS
|
|
150
|
+
|
|
52
151
|
# Option keys accepted by {#fsck}
|
|
53
152
|
#
|
|
54
153
|
# `:progress`/`:no_progress` are intentionally excluded: progress output is
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'git/commands/gc'
|
|
4
|
+
require 'git/commands/repack'
|
|
5
|
+
|
|
6
|
+
module Git
|
|
7
|
+
class Repository
|
|
8
|
+
# Facade methods for repository maintenance and optimization operations
|
|
9
|
+
#
|
|
10
|
+
# These methods pack objects, compress history, prune unreachable objects, and
|
|
11
|
+
# otherwise keep the repository in good health.
|
|
12
|
+
#
|
|
13
|
+
# Included by {Git::Repository}.
|
|
14
|
+
#
|
|
15
|
+
# @api public
|
|
16
|
+
#
|
|
17
|
+
module Maintenance
|
|
18
|
+
# Repack loose objects into pack files
|
|
19
|
+
#
|
|
20
|
+
# Packs all unpacked objects and removes redundant pack files. This is
|
|
21
|
+
# equivalent to running `git repack -a -d`, which packs all objects into a
|
|
22
|
+
# single pack and deletes any packs that become redundant.
|
|
23
|
+
#
|
|
24
|
+
# This method uses the fixed options `a: true, d: true` (matching the 4.x
|
|
25
|
+
# behavior). No additional options are exposed.
|
|
26
|
+
#
|
|
27
|
+
# @example Repack the repository
|
|
28
|
+
# repo.repack
|
|
29
|
+
#
|
|
30
|
+
# @return [String] the stdout from `git repack`. Git writes all progress
|
|
31
|
+
# and summary output to stderr, so the returned string is typically empty.
|
|
32
|
+
# Returns `String` to match the 4.x public contract (`Git::Lib#command`
|
|
33
|
+
# returned `result.stdout`).
|
|
34
|
+
#
|
|
35
|
+
# @raise [Git::FailedError] when git exits with a non-zero exit status
|
|
36
|
+
#
|
|
37
|
+
def repack
|
|
38
|
+
Git::Commands::Repack.new(@execution_context).call(a: true, d: true).stdout
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Run garbage collection to optimize and clean up the repository
|
|
42
|
+
#
|
|
43
|
+
# Runs `git gc` to perform housekeeping tasks including object compression,
|
|
44
|
+
# pruning of unreachable objects, and ref packing. This is equivalent to
|
|
45
|
+
# running `git gc --prune --aggressive --auto`.
|
|
46
|
+
#
|
|
47
|
+
# This method uses the fixed options `prune: true, aggressive: true, auto: true`
|
|
48
|
+
# (matching the 4.x behavior). No additional options are exposed.
|
|
49
|
+
#
|
|
50
|
+
# @example Run garbage collection
|
|
51
|
+
# repo.gc
|
|
52
|
+
#
|
|
53
|
+
# @return [String] the stdout from `git gc`. Git writes all progress
|
|
54
|
+
# and summary output to stderr, so the returned string is typically empty.
|
|
55
|
+
# Returns `String` to match the 4.x public contract (`Git::Lib#command`
|
|
56
|
+
# returned `result.stdout`).
|
|
57
|
+
#
|
|
58
|
+
# @raise [Git::FailedError] when git exits with a non-zero exit status
|
|
59
|
+
#
|
|
60
|
+
def gc
|
|
61
|
+
Git::Commands::Gc.new(@execution_context).call(prune: true, aggressive: true, auto: true).stdout
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -145,6 +145,24 @@ module Git
|
|
|
145
145
|
result.stdout.lines.map(&:strip).reject(&:empty?)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
+
# Return the paths of files with unresolved merge conflicts
|
|
149
|
+
#
|
|
150
|
+
# @example List conflicting files after a failed merge
|
|
151
|
+
# paths = repo.unmerged
|
|
152
|
+
# # => ["config/settings.rb", "lib/git/base.rb"]
|
|
153
|
+
# paths.each { |path| puts "Conflict in #{path}" }
|
|
154
|
+
#
|
|
155
|
+
# @return [Array<String>] repository-relative paths of files with unresolved
|
|
156
|
+
# merge conflicts; empty array when the working tree has no conflicts
|
|
157
|
+
#
|
|
158
|
+
# @raise [Git::FailedError] if git exits outside the allowed range (exit code > 2)
|
|
159
|
+
#
|
|
160
|
+
# @see #each_conflict
|
|
161
|
+
#
|
|
162
|
+
def unmerged
|
|
163
|
+
Private.unmerged_paths(@execution_context)
|
|
164
|
+
end
|
|
165
|
+
|
|
148
166
|
# Iterate over files with merge conflicts, yielding conflict details for each
|
|
149
167
|
#
|
|
150
168
|
# For each unmerged file, the staged content for both sides of the conflict
|
|
@@ -163,7 +181,8 @@ module Git
|
|
|
163
181
|
#
|
|
164
182
|
# @return [Array<String>] the list of unmerged file paths
|
|
165
183
|
#
|
|
166
|
-
# @raise [Git::FailedError] when `git diff --cached` exits
|
|
184
|
+
# @raise [Git::FailedError] when `git diff --cached` exits outside the
|
|
185
|
+
# allowed range (exit code > 2)
|
|
167
186
|
#
|
|
168
187
|
# @yield [file, your_version, their_version] passes conflict details for
|
|
169
188
|
# each unmerged file
|
|
@@ -189,6 +208,49 @@ module Git
|
|
|
189
208
|
end
|
|
190
209
|
end
|
|
191
210
|
|
|
211
|
+
# Iterate over files with merge conflicts, yielding conflict details for each
|
|
212
|
+
#
|
|
213
|
+
# For each unmerged file, the staged content for both sides of the conflict
|
|
214
|
+
# (stage 2 "ours" and stage 3 "theirs") is written to temporary files whose
|
|
215
|
+
# paths are yielded alongside the file path. The temporary files are deleted
|
|
216
|
+
# automatically when the block returns.
|
|
217
|
+
#
|
|
218
|
+
# @example Inspect conflicting files
|
|
219
|
+
# repo.conflicts do |file, your_version, their_version|
|
|
220
|
+
# puts "Conflict in #{file}"
|
|
221
|
+
# puts File.read(your_version)
|
|
222
|
+
# puts File.read(their_version)
|
|
223
|
+
# end
|
|
224
|
+
#
|
|
225
|
+
# @return [Array<String>] the list of unmerged file paths
|
|
226
|
+
#
|
|
227
|
+
# @raise [Git::FailedError] when `git diff --cached` exits outside the
|
|
228
|
+
# allowed range (exit code > 2)
|
|
229
|
+
#
|
|
230
|
+
# @yield [file, your_version, their_version] passes conflict details for
|
|
231
|
+
# each unmerged file
|
|
232
|
+
#
|
|
233
|
+
# @yieldparam file [String] path to the conflicting file, relative to the
|
|
234
|
+
# working tree
|
|
235
|
+
#
|
|
236
|
+
# @yieldparam your_version [String] path to a temporary file containing the
|
|
237
|
+
# stage-2 (ours) content for the conflicting file
|
|
238
|
+
#
|
|
239
|
+
# @yieldparam their_version [String] path to a temporary file containing the
|
|
240
|
+
# stage-3 (theirs) content for the conflicting file
|
|
241
|
+
#
|
|
242
|
+
# @yieldreturn [void]
|
|
243
|
+
#
|
|
244
|
+
# @deprecated Use {#each_conflict} instead
|
|
245
|
+
#
|
|
246
|
+
def conflicts(&)
|
|
247
|
+
Git::Deprecation.warn(
|
|
248
|
+
'Git::Repository#conflicts is deprecated and will be removed in a future version. ' \
|
|
249
|
+
'Use Git::Repository#each_conflict instead.'
|
|
250
|
+
)
|
|
251
|
+
each_conflict(&)
|
|
252
|
+
end
|
|
253
|
+
|
|
192
254
|
# Option keys accepted by {#revert}
|
|
193
255
|
#
|
|
194
256
|
# Derived from the 4.x option map for `Git::Lib#revert`.
|
|
@@ -89,6 +89,18 @@ module Git
|
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
+
# Alias for {#cat_file_contents}; retained for backward compatibility
|
|
93
|
+
#
|
|
94
|
+
# @see #cat_file_contents
|
|
95
|
+
alias cat_file cat_file_contents
|
|
96
|
+
|
|
97
|
+
# Alias for {#cat_file_contents}
|
|
98
|
+
#
|
|
99
|
+
# @deprecated Use {#cat_file_contents} instead
|
|
100
|
+
#
|
|
101
|
+
# @see #cat_file_contents
|
|
102
|
+
alias object_contents cat_file_contents
|
|
103
|
+
|
|
92
104
|
# Returns the size of a git object in bytes
|
|
93
105
|
#
|
|
94
106
|
# @example Get the size of a commit object
|
|
@@ -113,6 +125,13 @@ module Git
|
|
|
113
125
|
Git::Commands::CatFile::Raw.new(@execution_context).call(object, s: true).stdout.chomp.to_i
|
|
114
126
|
end
|
|
115
127
|
|
|
128
|
+
# Alias for {#cat_file_size}
|
|
129
|
+
#
|
|
130
|
+
# @deprecated Use {#cat_file_size} instead
|
|
131
|
+
#
|
|
132
|
+
# @see #cat_file_size
|
|
133
|
+
alias object_size cat_file_size
|
|
134
|
+
|
|
116
135
|
# Returns the type of a git object
|
|
117
136
|
#
|
|
118
137
|
# @example Get the type of a commit reference
|
|
@@ -138,6 +157,13 @@ module Git
|
|
|
138
157
|
Git::Commands::CatFile::Raw.new(@execution_context).call(object, t: true).stdout.chomp
|
|
139
158
|
end
|
|
140
159
|
|
|
160
|
+
# Alias for {#cat_file_type}
|
|
161
|
+
#
|
|
162
|
+
# @deprecated Use {#cat_file_type} instead
|
|
163
|
+
#
|
|
164
|
+
# @see #cat_file_type
|
|
165
|
+
alias object_type cat_file_type
|
|
166
|
+
|
|
141
167
|
# Returns parsed commit data for the given git object
|
|
142
168
|
#
|
|
143
169
|
# @example Get commit data for HEAD
|
|
@@ -174,6 +200,13 @@ module Git
|
|
|
174
200
|
Git::Parsers::CatFile.parse_commit(result.stdout.split("\n"), object)
|
|
175
201
|
end
|
|
176
202
|
|
|
203
|
+
# Alias for {#cat_file_commit}
|
|
204
|
+
#
|
|
205
|
+
# @deprecated Use {#cat_file_commit} instead
|
|
206
|
+
#
|
|
207
|
+
# @see #cat_file_commit
|
|
208
|
+
alias commit_data cat_file_commit
|
|
209
|
+
|
|
177
210
|
# Returns parsed tag data for the given annotated tag object
|
|
178
211
|
#
|
|
179
212
|
# Does not work with lightweight tags. To list all annotated tags in a
|
|
@@ -223,6 +256,13 @@ module Git
|
|
|
223
256
|
Git::Parsers::CatFile.parse_tag(tdata, object)
|
|
224
257
|
end
|
|
225
258
|
|
|
259
|
+
# Alias for {#cat_file_tag}
|
|
260
|
+
#
|
|
261
|
+
# @deprecated Use {#cat_file_tag} instead
|
|
262
|
+
#
|
|
263
|
+
# @see #cat_file_tag
|
|
264
|
+
alias tag_data cat_file_tag
|
|
265
|
+
|
|
226
266
|
# Resolve a revision specifier to its full object ID
|
|
227
267
|
#
|
|
228
268
|
# Passes the given revision specifier to `git rev-parse` and returns the
|
|
@@ -252,6 +292,8 @@ module Git
|
|
|
252
292
|
Git::Commands::RevParse.new(@execution_context).call(objectish, '--', revs_only: true).stdout
|
|
253
293
|
end
|
|
254
294
|
|
|
295
|
+
alias revparse rev_parse
|
|
296
|
+
|
|
255
297
|
# Returns the SHA of a named tag
|
|
256
298
|
#
|
|
257
299
|
# Returns an empty string when the tag does not exist.
|
|
@@ -353,6 +395,13 @@ module Git
|
|
|
353
395
|
Git::Commands::NameRev.new(@execution_context).call(commit_ish).stdout.split[1]
|
|
354
396
|
end
|
|
355
397
|
|
|
398
|
+
# Alias for {#name_rev}
|
|
399
|
+
#
|
|
400
|
+
# @deprecated Use {#name_rev} instead
|
|
401
|
+
#
|
|
402
|
+
# @see #name_rev
|
|
403
|
+
alias namerev name_rev
|
|
404
|
+
|
|
356
405
|
# Option keys accepted by {#ls_tree}
|
|
357
406
|
LS_TREE_ALLOWED_OPTS = %i[recursive path].freeze
|
|
358
407
|
private_constant :LS_TREE_ALLOWED_OPTS
|
|
@@ -704,25 +753,25 @@ module Git
|
|
|
704
753
|
Git::Parsers::Tag.parse_list(result.stdout).map { |info| tag(info.name) }
|
|
705
754
|
end
|
|
706
755
|
|
|
707
|
-
# Option keys accepted by {#
|
|
708
|
-
|
|
756
|
+
# Option keys accepted by {#tag_add}
|
|
757
|
+
TAG_ADD_ALLOWED_OPTS = %i[
|
|
709
758
|
annotate a sign s no_sign local_user u force f message m file F
|
|
710
759
|
edit e no_edit trailer cleanup create_reflog
|
|
711
760
|
].freeze
|
|
712
|
-
private_constant :
|
|
761
|
+
private_constant :TAG_ADD_ALLOWED_OPTS
|
|
713
762
|
|
|
714
763
|
# Create a new tag
|
|
715
764
|
#
|
|
716
|
-
# @overload
|
|
765
|
+
# @overload tag_add(name, options = {})
|
|
717
766
|
#
|
|
718
767
|
# @example Create a lightweight tag on HEAD
|
|
719
|
-
# repo.
|
|
768
|
+
# repo.tag_add('v1.0.0')
|
|
720
769
|
#
|
|
721
770
|
# @example Create an annotated tag on HEAD
|
|
722
|
-
# repo.
|
|
771
|
+
# repo.tag_add('v1.0.0', annotate: true, message: 'Release 1.0.0')
|
|
723
772
|
#
|
|
724
773
|
# @example Replace an existing tag on HEAD
|
|
725
|
-
# repo.
|
|
774
|
+
# repo.tag_add('v1.0.0', force: true)
|
|
726
775
|
#
|
|
727
776
|
# @param name [String] the name of the tag to create
|
|
728
777
|
#
|
|
@@ -779,13 +828,13 @@ module Git
|
|
|
779
828
|
#
|
|
780
829
|
# @return [Git::Object::Tag] the newly created tag
|
|
781
830
|
#
|
|
782
|
-
# @overload
|
|
831
|
+
# @overload tag_add(name, target, options = {})
|
|
783
832
|
#
|
|
784
833
|
# @example Create a lightweight tag on a specific commit
|
|
785
|
-
# repo.
|
|
834
|
+
# repo.tag_add('v1.0.0', 'abc123')
|
|
786
835
|
#
|
|
787
836
|
# @example Create an annotated tag on a specific commit
|
|
788
|
-
# repo.
|
|
837
|
+
# repo.tag_add('v1.0.0', 'abc123', annotate: true, message: 'Release 1.0.0')
|
|
789
838
|
#
|
|
790
839
|
# @param name [String] the name of the tag to create
|
|
791
840
|
#
|
|
@@ -796,20 +845,18 @@ module Git
|
|
|
796
845
|
#
|
|
797
846
|
# @return [Git::Object::Tag] the newly created tag
|
|
798
847
|
#
|
|
799
|
-
# @overload
|
|
848
|
+
# @overload tag_add(name, delete_options)
|
|
800
849
|
#
|
|
801
|
-
# @deprecated Use {#
|
|
850
|
+
# @deprecated Use {#tag_delete} instead.
|
|
802
851
|
#
|
|
803
852
|
# @example Delete a tag (deprecated)
|
|
804
|
-
# repo.
|
|
853
|
+
# repo.tag_add('v1.0.0', d: true)
|
|
805
854
|
#
|
|
806
855
|
# @param name [String] the name of the tag to delete
|
|
807
856
|
#
|
|
808
|
-
# @
|
|
809
|
-
#
|
|
810
|
-
#
|
|
811
|
-
# @option options [Boolean, nil] :delete (nil) delete the named tag
|
|
812
|
-
# (alias: `:d`); deprecated — use {#delete_tag} instead
|
|
857
|
+
# @param delete_options [{ d: true }, { delete: true }] deletion options;
|
|
858
|
+
# only `:d` or `:delete` (set to `true`) is accepted — no other keys
|
|
859
|
+
# and no `target` argument may be combined with this form
|
|
813
860
|
#
|
|
814
861
|
# @return [String] git's stdout from the delete
|
|
815
862
|
#
|
|
@@ -825,23 +872,58 @@ module Git
|
|
|
825
872
|
#
|
|
826
873
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
827
874
|
#
|
|
828
|
-
def
|
|
829
|
-
|
|
830
|
-
target =
|
|
875
|
+
def tag_add(name, *args)
|
|
876
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
877
|
+
target = args.first
|
|
831
878
|
|
|
832
|
-
return Private.
|
|
879
|
+
return Private.tag_add_delete_deprecated(self, name, target, options) if options[:d] || options[:delete]
|
|
833
880
|
|
|
834
|
-
|
|
835
|
-
SharedPrivate.assert_valid_opts!(
|
|
836
|
-
Private.validate_tag_options!(
|
|
837
|
-
Git::Commands::Tag::Create.new(@execution_context).call(name, target, **
|
|
881
|
+
options = options.except(:d, :delete)
|
|
882
|
+
SharedPrivate.assert_valid_opts!(TAG_ADD_ALLOWED_OPTS, **options)
|
|
883
|
+
Private.validate_tag_options!(options)
|
|
884
|
+
Git::Commands::Tag::Create.new(@execution_context).call(name, target, **options)
|
|
838
885
|
tag(name)
|
|
839
886
|
end
|
|
840
887
|
|
|
888
|
+
# @deprecated Use {#tag_add} instead.
|
|
889
|
+
#
|
|
890
|
+
# @overload add_tag(name, options = {})
|
|
891
|
+
#
|
|
892
|
+
# @param name [String] the name of the tag to create
|
|
893
|
+
#
|
|
894
|
+
# @param options [Hash] options for creating the tag
|
|
895
|
+
#
|
|
896
|
+
# @return [Git::Object::Tag] the newly created tag
|
|
897
|
+
#
|
|
898
|
+
# @overload add_tag(name, target, options = {})
|
|
899
|
+
#
|
|
900
|
+
# @param name [String] the name of the tag to create
|
|
901
|
+
#
|
|
902
|
+
# @param target [String] the object to tag (commit SHA, branch name, etc.)
|
|
903
|
+
#
|
|
904
|
+
# @param options [Hash] options for creating the tag
|
|
905
|
+
#
|
|
906
|
+
# @return [Git::Object::Tag] the newly created tag
|
|
907
|
+
#
|
|
908
|
+
# @raise [ArgumentError] if unsupported options are provided
|
|
909
|
+
#
|
|
910
|
+
# @raise [ArgumentError] if an annotated or signed tag is requested without
|
|
911
|
+
# a message
|
|
912
|
+
#
|
|
913
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
914
|
+
#
|
|
915
|
+
def add_tag(name, *options)
|
|
916
|
+
Git::Deprecation.warn(
|
|
917
|
+
'Git::Repository#add_tag is deprecated and will be removed in v6.0.0. ' \
|
|
918
|
+
'Use Git::Repository#tag_add instead.'
|
|
919
|
+
)
|
|
920
|
+
tag_add(name, *options)
|
|
921
|
+
end
|
|
922
|
+
|
|
841
923
|
# Delete a tag
|
|
842
924
|
#
|
|
843
925
|
# @example Delete a tag
|
|
844
|
-
# repo.
|
|
926
|
+
# repo.tag_delete('v1.0.0')
|
|
845
927
|
#
|
|
846
928
|
# @param name [String] the name of the tag to delete
|
|
847
929
|
#
|
|
@@ -849,13 +931,29 @@ module Git
|
|
|
849
931
|
#
|
|
850
932
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
851
933
|
#
|
|
852
|
-
def
|
|
934
|
+
def tag_delete(name)
|
|
853
935
|
result = Git::Commands::Tag::Delete.new(@execution_context).call(name)
|
|
854
936
|
raise Git::FailedError, result if result.status.exitstatus.positive?
|
|
855
937
|
|
|
856
938
|
result.stdout
|
|
857
939
|
end
|
|
858
940
|
|
|
941
|
+
# @deprecated Use {#tag_delete} instead.
|
|
942
|
+
#
|
|
943
|
+
# @param name [String] the name of the tag to delete
|
|
944
|
+
#
|
|
945
|
+
# @return [String] git's stdout from the delete
|
|
946
|
+
#
|
|
947
|
+
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
948
|
+
#
|
|
949
|
+
def delete_tag(name)
|
|
950
|
+
Git::Deprecation.warn(
|
|
951
|
+
'Git::Repository#delete_tag is deprecated and will be removed in v6.0.0. ' \
|
|
952
|
+
'Use Git::Repository#tag_delete instead.'
|
|
953
|
+
)
|
|
954
|
+
tag_delete(name)
|
|
955
|
+
end
|
|
956
|
+
|
|
859
957
|
# Private helpers
|
|
860
958
|
#
|
|
861
959
|
# @api private
|
|
@@ -882,9 +980,9 @@ module Git
|
|
|
882
980
|
raise ArgumentError, 'Cannot create an annotated or signed tag without a message.'
|
|
883
981
|
end
|
|
884
982
|
|
|
885
|
-
# Handle the deprecated :d/:delete option on
|
|
983
|
+
# Handle the deprecated :d/:delete option on tag_add
|
|
886
984
|
#
|
|
887
|
-
# Issues a deprecation warning and delegates to
|
|
985
|
+
# Issues a deprecation warning and delegates to tag_delete. Raises
|
|
888
986
|
# ArgumentError if a target or incompatible options are also supplied.
|
|
889
987
|
#
|
|
890
988
|
# @param facade [ObjectOperations] the calling facade instance
|
|
@@ -892,21 +990,21 @@ module Git
|
|
|
892
990
|
# @param target [String, nil] target argument (must be nil)
|
|
893
991
|
# @param opts [Hash] options hash (must contain only :d/:delete)
|
|
894
992
|
#
|
|
895
|
-
# @return [String] stdout from
|
|
993
|
+
# @return [String] stdout from tag_delete
|
|
896
994
|
#
|
|
897
995
|
# @api private
|
|
898
996
|
#
|
|
899
|
-
def
|
|
997
|
+
def tag_add_delete_deprecated(facade, name, target, opts)
|
|
900
998
|
Git::Deprecation.warn(
|
|
901
|
-
'Passing :d or :delete to
|
|
902
|
-
'
|
|
999
|
+
'Passing :d or :delete to tag_add is deprecated and will be removed in v6.0.0. ' \
|
|
1000
|
+
'Use tag_delete instead.'
|
|
903
1001
|
)
|
|
904
1002
|
raise ArgumentError, 'Cannot pass a target when using the :d/:delete option.' if target
|
|
905
1003
|
|
|
906
1004
|
extra = opts.keys - %i[d delete]
|
|
907
1005
|
raise ArgumentError, "Cannot combine :d/:delete with other options: #{extra.join(', ')}" unless extra.empty?
|
|
908
1006
|
|
|
909
|
-
facade.
|
|
1007
|
+
facade.tag_delete(name)
|
|
910
1008
|
end
|
|
911
1009
|
|
|
912
1010
|
def show_ref_tag_sha(execution_context, tag_name)
|
|
@@ -70,7 +70,7 @@ module Git
|
|
|
70
70
|
# @param binary_path [String, :use_global_config] path to the git binary
|
|
71
71
|
#
|
|
72
72
|
# Controls which git binary is invoked during root detection. Defaults to
|
|
73
|
-
# `:use_global_config`, which resolves to `Git
|
|
73
|
+
# `:use_global_config`, which resolves to `Git.config.binary_path`.
|
|
74
74
|
#
|
|
75
75
|
# @param git_ssh [String, nil, :use_global_config] the SSH wrapper path
|
|
76
76
|
#
|