git 5.7.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +132 -42
- data/CONTRIBUTING.md +44 -31
- data/README.md +138 -100
- data/UPGRADING.md +864 -259
- data/git.gemspec +6 -8
- data/lib/git/author_info.rb +1 -2
- data/lib/git/commands/base.rb +22 -2
- data/lib/git/commands/cat_file/raw.rb +0 -68
- data/lib/git/commands/maintenance/register.rb +0 -4
- data/lib/git/commands/maintenance/run.rb +0 -4
- data/lib/git/commands/maintenance/start.rb +0 -4
- data/lib/git/commands/maintenance/stop.rb +0 -4
- data/lib/git/commands/maintenance/unregister.rb +0 -4
- data/lib/git/commands/maintenance.rb +0 -2
- data/lib/git/commands/show_ref/exclude_existing.rb +1 -1
- data/lib/git/commands/show_ref/exists.rb +0 -5
- data/lib/git/commands/show_ref/list.rb +1 -1
- data/lib/git/commands/show_ref/verify.rb +1 -1
- data/lib/git/commands/show_ref.rb +1 -1
- data/lib/git/commands/worktree/repair.rb +0 -5
- data/lib/git/diff_path_status.rb +1 -1
- data/lib/git/encoding_utils.rb +25 -0
- data/lib/git/errors.rb +24 -18
- data/lib/git/factories.rb +361 -125
- data/lib/git/log.rb +3 -75
- data/lib/git/object.rb +4 -185
- data/lib/git/path_resolver.rb +104 -36
- data/lib/git/repository/branching.rb +21 -189
- data/lib/git/repository/committing.rb +0 -25
- data/lib/git/repository/context_helpers.rb +249 -155
- data/lib/git/repository/diffing.rb +2 -72
- data/lib/git/repository/merging.rb +32 -54
- data/lib/git/repository/object_operations.rb +120 -497
- data/lib/git/repository/remote_operations.rb +7 -219
- data/lib/git/repository/staging.rb +6 -184
- data/lib/git/repository/stashing.rb +126 -130
- data/lib/git/repository/status_operations.rb +1 -54
- data/lib/git/repository/worktree_operations.rb +30 -125
- data/lib/git/repository.rb +20 -299
- data/lib/git/system_call_guard.rb +95 -0
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +47 -364
- metadata +24 -18
- data/lib/git/author.rb +0 -46
- data/lib/git/branch.rb +0 -693
- data/lib/git/branches.rb +0 -194
- data/lib/git/remote.rb +0 -191
- data/lib/git/stash.rb +0 -124
- data/lib/git/stashes.rb +0 -198
- data/lib/git/status.rb +0 -384
- data/lib/git/worktree.rb +0 -180
- data/lib/git/worktrees.rb +0 -152
data/lib/git.rb
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# active_support/deprecation alone does not load everything its built-in
|
|
4
|
+
# behaviors use: :log reaches ActiveSupport::IsolatedExecutionState through the
|
|
5
|
+
# logger and :report reaches ActiveSupport.error_reporter. Outside Rails nothing
|
|
6
|
+
# else loads them, so require the ActiveSupport entry point first.
|
|
7
|
+
require 'active_support'
|
|
3
8
|
require 'active_support/deprecation'
|
|
4
9
|
|
|
5
10
|
# Define Git::Deprecation before requiring the rest of the library to ensure that
|
|
@@ -7,10 +12,33 @@ require 'active_support/deprecation'
|
|
|
7
12
|
# configured according to the GIT_DEPRECATION_BEHAVIOR environment variable.
|
|
8
13
|
#
|
|
9
14
|
module Git
|
|
15
|
+
# The gem name handed to ActiveSupport::Deprecation
|
|
16
|
+
#
|
|
17
|
+
# ActiveSupport's :notify behavior builds its notification name by calling
|
|
18
|
+
# `underscore` on the gem name. That is a String core extension this gem does
|
|
19
|
+
# not load, because requiring it adds twenty-one methods to String in every
|
|
20
|
+
# process that loads the gem. This subclass answers `underscore` itself, so
|
|
21
|
+
# :notify works and String stays untouched. Everywhere else ActiveSupport
|
|
22
|
+
# interpolates the name or passes it through, where it behaves as "Git".
|
|
23
|
+
#
|
|
24
|
+
# @api private
|
|
25
|
+
class DeprecationGemName < String
|
|
26
|
+
# The segment of the notification name after "deprecation."
|
|
27
|
+
#
|
|
28
|
+
# @return [String] "git"
|
|
29
|
+
def underscore = 'git'
|
|
30
|
+
end
|
|
31
|
+
private_constant :DeprecationGemName
|
|
32
|
+
|
|
10
33
|
# The deprecation instance used to emit deprecation warnings for the Git gem
|
|
11
34
|
#
|
|
35
|
+
# ActiveSupport defaults the deprecation horizon to a Rails version, and this
|
|
36
|
+
# gem never interpolates it into a warning: every warning is written by hand
|
|
37
|
+
# per ADR-0007. The horizon is informational only, so it carries the ADR's
|
|
38
|
+
# wording instead of a version that would go stale.
|
|
39
|
+
#
|
|
12
40
|
# @api public
|
|
13
|
-
Deprecation = ActiveSupport::Deprecation.new('
|
|
41
|
+
Deprecation = ActiveSupport::Deprecation.new('in a future major release', DeprecationGemName.new('Git'))
|
|
14
42
|
|
|
15
43
|
# Configure a deprecation instance from a GIT_DEPRECATION_BEHAVIOR value
|
|
16
44
|
#
|
|
@@ -45,11 +73,8 @@ module Git
|
|
|
45
73
|
configure_deprecation_behavior(Deprecation, ENV.fetch('GIT_DEPRECATION_BEHAVIOR', nil))
|
|
46
74
|
end
|
|
47
75
|
|
|
48
|
-
require 'git/author'
|
|
49
76
|
require 'git/author_info'
|
|
50
|
-
require 'git/branch'
|
|
51
77
|
require 'git/branch_info'
|
|
52
|
-
require 'git/branches'
|
|
53
78
|
require 'git/command_line'
|
|
54
79
|
require 'process_executer'
|
|
55
80
|
require 'git/config'
|
|
@@ -80,23 +105,18 @@ require 'git/version_constraint'
|
|
|
80
105
|
require 'git/commands'
|
|
81
106
|
require 'git/log'
|
|
82
107
|
require 'git/object'
|
|
83
|
-
require 'git/remote'
|
|
84
108
|
require 'git/remote_info'
|
|
85
109
|
require 'git/repository'
|
|
86
|
-
require 'git/status'
|
|
87
110
|
require 'git/status_file_info'
|
|
88
111
|
require 'git/status_info'
|
|
89
|
-
require 'git/stash'
|
|
90
112
|
require 'git/stash_info'
|
|
91
|
-
require 'git/
|
|
113
|
+
require 'git/system_call_guard'
|
|
92
114
|
require 'git/tag_delete_failure'
|
|
93
115
|
require 'git/tag_delete_result'
|
|
94
116
|
require 'git/tag_info'
|
|
95
117
|
require 'git/url'
|
|
96
118
|
require 'git/version'
|
|
97
|
-
require 'git/worktree'
|
|
98
119
|
require 'git/worktree_info'
|
|
99
|
-
require 'git/worktrees'
|
|
100
120
|
|
|
101
121
|
# The Git module provides the basic functions to open a git
|
|
102
122
|
# reference to work with. You can open a working directory,
|
|
@@ -116,103 +136,7 @@ module Git
|
|
|
116
136
|
#
|
|
117
137
|
# @api public
|
|
118
138
|
#
|
|
119
|
-
MINIMUM_GIT_VERSION = Version.parse('2.
|
|
120
|
-
|
|
121
|
-
# Compatibility shim for code that monkeypatches the `Git::Base` class from
|
|
122
|
-
# versions prior to 5.0.0.
|
|
123
|
-
#
|
|
124
|
-
# `Git::Base` is a module included in {Git::Repository}, so any instance
|
|
125
|
-
# methods added to `Git::Base` are automatically available on
|
|
126
|
-
# {Git::Repository} instances. A deprecation warning is emitted for each
|
|
127
|
-
# method added, encouraging migration to an application-owned extension module.
|
|
128
|
-
#
|
|
129
|
-
# @example Monkeypatching Git::Base (deprecated)
|
|
130
|
-
# module Git::Base
|
|
131
|
-
# def my_helper = "hello"
|
|
132
|
-
# end
|
|
133
|
-
# Git.open('.').my_helper # => "hello"
|
|
134
|
-
#
|
|
135
|
-
# @deprecated Move custom methods to an application-owned extension module and
|
|
136
|
-
# include or prepend it into {Git::Repository}.
|
|
137
|
-
#
|
|
138
|
-
# @api public
|
|
139
|
-
Base = Module.new do
|
|
140
|
-
# Emit a deprecation warning each time a method is defined in Git::Base so
|
|
141
|
-
# that authors of monkeypatches are nudged toward application-owned extensions.
|
|
142
|
-
def self.method_added(method_name)
|
|
143
|
-
Git::Deprecation.warn(
|
|
144
|
-
'Monkeypatching Git::Base is deprecated and will be removed in v6.0.0. ' \
|
|
145
|
-
"Move #{method_name} to an application-owned extension module for Git::Repository."
|
|
146
|
-
)
|
|
147
|
-
super
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
# Raise a clear error when legacy code calls Git::Base.new directly.
|
|
151
|
-
def self.new(...)
|
|
152
|
-
raise NoMethodError,
|
|
153
|
-
'Git::Base.new is not supported. Use Git.open, Git.clone, or Git.init instead.'
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
Repository.include(Base)
|
|
158
|
-
|
|
159
|
-
# Intercept the first lookup of the deprecated `Git::CommandLineResult` constant
|
|
160
|
-
#
|
|
161
|
-
# When `name` is `:CommandLineResult`, caches and returns {Git::CommandLine::Result}
|
|
162
|
-
# after emitting a deprecation warning. Calls `super` for any other unknown constant,
|
|
163
|
-
# preserving normal Ruby `NameError` behavior.
|
|
164
|
-
#
|
|
165
|
-
# @param name [Symbol] the name of the missing constant
|
|
166
|
-
#
|
|
167
|
-
# @return [Class] the resolved constant value
|
|
168
|
-
#
|
|
169
|
-
# @api private
|
|
170
|
-
def self.const_missing(name)
|
|
171
|
-
return super unless name == :CommandLineResult
|
|
172
|
-
|
|
173
|
-
# Cache the constant first so subsequent accesses are zero-cost even if
|
|
174
|
-
# the deprecation behavior raises (e.g. in the test suite).
|
|
175
|
-
const_set(:CommandLineResult, Git::CommandLine::Result)
|
|
176
|
-
Git::Deprecation.warn(
|
|
177
|
-
'Git::CommandLineResult is deprecated and will be removed in v6.0.0. ' \
|
|
178
|
-
'Use Git::CommandLine::Result instead.'
|
|
179
|
-
)
|
|
180
|
-
Git::CommandLine::Result
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
# Gets or sets local git configuration options
|
|
184
|
-
#
|
|
185
|
-
# @overload config(name, value)
|
|
186
|
-
# Set the value for the git named configuration option
|
|
187
|
-
#
|
|
188
|
-
# @param name [String] the name of the git configuration option
|
|
189
|
-
#
|
|
190
|
-
# @param value [String, Boolean] the value to set for the git configuration option
|
|
191
|
-
#
|
|
192
|
-
# @return [Git::CommandLine::Result] the result of the git configuration command
|
|
193
|
-
#
|
|
194
|
-
# @overload config(name)
|
|
195
|
-
# Get the value for the git named configuration option
|
|
196
|
-
#
|
|
197
|
-
# @param name [String] the name of the git configuration option
|
|
198
|
-
#
|
|
199
|
-
# @return [String] the value of the git configuration option
|
|
200
|
-
#
|
|
201
|
-
# @overload config()
|
|
202
|
-
# List all git configuration options
|
|
203
|
-
#
|
|
204
|
-
# @return [Hash{String => String}] a hash of all git configuration options
|
|
205
|
-
#
|
|
206
|
-
# @deprecated Mixing in the `Git` module is deprecated and will be removed in v6.0.0.
|
|
207
|
-
# Use `Git.config_get(name)`, `Git.config_set(name, value)`, or `Git.config_list` instead.
|
|
208
|
-
#
|
|
209
|
-
def config(name = nil, value = nil)
|
|
210
|
-
Git::Deprecation.warn(
|
|
211
|
-
'Git#config is deprecated and will be removed in v6.0.0. ' \
|
|
212
|
-
'Use Git.config_get(name), Git.config_set(name, value), or Git.config_list instead.'
|
|
213
|
-
)
|
|
214
|
-
Git.__send__(:legacy_config_set_get_list, name, value, global: false)
|
|
215
|
-
end
|
|
139
|
+
MINIMUM_GIT_VERSION = Version.parse('2.43.0')
|
|
216
140
|
|
|
217
141
|
# Configures the gem by yielding {Git::Config.instance} to the block
|
|
218
142
|
#
|
|
@@ -243,41 +167,6 @@ module Git
|
|
|
243
167
|
Git::Config.instance
|
|
244
168
|
end
|
|
245
169
|
|
|
246
|
-
# Gets or sets global git configuration options
|
|
247
|
-
#
|
|
248
|
-
# @overload global_config(name, value)
|
|
249
|
-
# Set the value for the git named configuration option
|
|
250
|
-
#
|
|
251
|
-
# @param name [String] the name of the git configuration option
|
|
252
|
-
#
|
|
253
|
-
# @param value [String, Boolean] the value to set for the git configuration option
|
|
254
|
-
#
|
|
255
|
-
# @return [Git::CommandLine::Result] the result of the git configuration command
|
|
256
|
-
#
|
|
257
|
-
# @overload global_config(name)
|
|
258
|
-
# Get the value for the git named configuration option
|
|
259
|
-
#
|
|
260
|
-
# @param name [String] the name of the git configuration option
|
|
261
|
-
#
|
|
262
|
-
# @return [String] the value of the git configuration option
|
|
263
|
-
#
|
|
264
|
-
# @overload global_config()
|
|
265
|
-
# List all git configuration options
|
|
266
|
-
#
|
|
267
|
-
# @return [Hash{String => String}] a hash of all git configuration options
|
|
268
|
-
#
|
|
269
|
-
# @deprecated Mixing in the `Git` module is deprecated and will be removed in v6.0.0.
|
|
270
|
-
# Use `Git.config_get(name, global: true)`, `Git.config_set(name, value, global: true)`, or
|
|
271
|
-
# `Git.config_list(global: true)` instead.
|
|
272
|
-
def global_config(name = nil, value = nil)
|
|
273
|
-
Git::Deprecation.warn(
|
|
274
|
-
'Git#global_config is deprecated and will be removed in v6.0.0. ' \
|
|
275
|
-
'Use Git.config_get(name, global: true), Git.config_set(name, value, global: true), ' \
|
|
276
|
-
'or Git.config_list(global: true) instead.'
|
|
277
|
-
)
|
|
278
|
-
Git.__send__(:legacy_config_set_get_list, name, value, global: true)
|
|
279
|
-
end
|
|
280
|
-
|
|
281
170
|
# Returns the name of the default branch of the given repository
|
|
282
171
|
#
|
|
283
172
|
# @example with a URI string
|
|
@@ -332,8 +221,7 @@ module Git
|
|
|
332
221
|
# Nothing is cleaned up, because the exported files are the deliverable and the
|
|
333
222
|
# leftover has to be removed by hand once the cause of the failure is fixed.
|
|
334
223
|
#
|
|
335
|
-
# Takes the same options as {Git.clone} except that `:depth` defaults to 1
|
|
336
|
-
# `:remote` is ignored with a deprecation warning.
|
|
224
|
+
# Takes the same options as {Git.clone} except that `:depth` defaults to 1.
|
|
337
225
|
#
|
|
338
226
|
# @param repository_url [String, URI, Pathname] the repository to export from
|
|
339
227
|
#
|
|
@@ -342,10 +230,6 @@ module Git
|
|
|
342
230
|
#
|
|
343
231
|
# @param options [Hash] options forwarded to {Git.clone} (`:depth` defaults to 1)
|
|
344
232
|
#
|
|
345
|
-
# @option options [String] :remote deprecated and ignored; delete it from the call.
|
|
346
|
-
# Passing it emits a deprecation warning and it will be removed in a future
|
|
347
|
-
# major release.
|
|
348
|
-
#
|
|
349
233
|
# @option options [String] :branch the branch or tag to export instead of HEAD.
|
|
350
234
|
# Give the short name (`main`, `v1.0.0`); a full ref path such as
|
|
351
235
|
# `refs/tags/v1.0.0` or a commit SHA is not accepted. Use `:revision` to
|
|
@@ -353,53 +237,17 @@ module Git
|
|
|
353
237
|
#
|
|
354
238
|
# @return [void]
|
|
355
239
|
#
|
|
356
|
-
# @raise [
|
|
357
|
-
# files are left in place, and the directory keeps whatever part of `.git`
|
|
358
|
-
# not be deleted.
|
|
240
|
+
# @raise [Git::Error] if the `.git` directory cannot be removed. The exported
|
|
241
|
+
# files are left in place, and the directory keeps whatever part of `.git`
|
|
242
|
+
# could not be deleted.
|
|
359
243
|
#
|
|
360
244
|
def self.export(repository_url, directory = nil, options = {})
|
|
361
|
-
if options.key?(:remote)
|
|
362
|
-
Git::Deprecation.warn(
|
|
363
|
-
'The :remote option to Git.export is ignored, is deprecated, and will be removed in a future ' \
|
|
364
|
-
'major release. Delete it from the call.'
|
|
365
|
-
)
|
|
366
|
-
options.delete(:remote)
|
|
367
|
-
end
|
|
368
245
|
repo = clone(repository_url, directory, { depth: 1 }.merge(options))
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
# @example Set a value
|
|
375
|
-
# Git.global_config('user.name', 'Scott Chacon')
|
|
376
|
-
#
|
|
377
|
-
# @example Get a value
|
|
378
|
-
# Git.global_config('user.name') # => 'Scott Chacon'
|
|
379
|
-
#
|
|
380
|
-
# @example List all global config entries
|
|
381
|
-
# Git.global_config # => { 'user.name' => 'Scott Chacon', ... }
|
|
382
|
-
#
|
|
383
|
-
# @param name [String, nil] the config key to get or set; omit to list all
|
|
384
|
-
#
|
|
385
|
-
# @param value [Object, nil] the value to set; omit to get or list
|
|
386
|
-
#
|
|
387
|
-
# @return [String, Hash, Git::CommandLine::Result] the config value, all entries,
|
|
388
|
-
# or the result of the set command
|
|
389
|
-
#
|
|
390
|
-
# @deprecated Use {Git.config_get}, {Git.config_set}, or {Git.config_list} instead.
|
|
391
|
-
#
|
|
392
|
-
# - `Git.global_config('user.name')` → `Git.config_get('user.name', global: true)`
|
|
393
|
-
# - `Git.global_config('user.name', 'Bob')` → `Git.config_set('user.name', 'Bob', global: true)`
|
|
394
|
-
# - `Git.global_config` → `Git.config_list(global: true)`
|
|
395
|
-
#
|
|
396
|
-
def self.global_config(name = nil, value = nil)
|
|
397
|
-
Git::Deprecation.warn(
|
|
398
|
-
'Git.global_config is deprecated and will be removed in v6.0.0. ' \
|
|
399
|
-
'Use Git.config_get(name, global: true), Git.config_set(name, value, global: true), ' \
|
|
400
|
-
'or Git.config_list(global: true) instead.'
|
|
401
|
-
)
|
|
402
|
-
legacy_config_set_get_list(name, value, global: true)
|
|
246
|
+
git_dir = File.join(repo.dir.to_s, '.git')
|
|
247
|
+
Git::SystemCallGuard.call(
|
|
248
|
+
"Failed to remove '#{git_dir}'; the exported files are in place, but part of the " \
|
|
249
|
+
'repository remains and has to be removed by hand'
|
|
250
|
+
) { FileUtils.rm_r(git_dir) }
|
|
403
251
|
end
|
|
404
252
|
|
|
405
253
|
# Option keys accepted by {.ls_remote}
|
|
@@ -428,10 +276,10 @@ module Git
|
|
|
428
276
|
# @example From a specific remote of the current repository
|
|
429
277
|
# references = Git.ls_remote('origin')
|
|
430
278
|
#
|
|
431
|
-
# @param repository [String
|
|
279
|
+
# @param repository [String] the target repository location or the name of a remote
|
|
432
280
|
#
|
|
433
|
-
# Defaults to `'.'` (the current directory). Passing `nil`
|
|
434
|
-
#
|
|
281
|
+
# Defaults to `'.'` (the current directory). Passing `nil` raises
|
|
282
|
+
# `ArgumentError`; pass `'.'` or omit the argument.
|
|
435
283
|
#
|
|
436
284
|
# @param options [Hash] the options to pass to the git command
|
|
437
285
|
#
|
|
@@ -489,8 +337,11 @@ module Git
|
|
|
489
337
|
#
|
|
490
338
|
# @return [Hash{String => Hash}] the available references of the target repo
|
|
491
339
|
#
|
|
340
|
+
# @raise [ArgumentError] if `repository` is `nil` or `options` contains an unknown key
|
|
341
|
+
#
|
|
492
342
|
def self.ls_remote(repository = '.', options = {})
|
|
493
|
-
repository
|
|
343
|
+
raise ArgumentError, 'repository must not be nil' if repository.nil?
|
|
344
|
+
|
|
494
345
|
options = options.dup
|
|
495
346
|
log = options.delete(:log)
|
|
496
347
|
unknown = options.keys - LS_REMOTE_ALLOWED_OPTS
|
|
@@ -501,29 +352,6 @@ module Git
|
|
|
501
352
|
Git::Parsers::LsRemote.parse_output(output_lines)
|
|
502
353
|
end
|
|
503
354
|
|
|
504
|
-
# Normalize the repository argument for {.ls_remote}
|
|
505
|
-
#
|
|
506
|
-
# Returns the repository unchanged unless it is nil, in which case a
|
|
507
|
-
# deprecation warning is emitted and `'.'` is returned.
|
|
508
|
-
#
|
|
509
|
-
# @param repository [String, nil] the repository argument passed by the caller
|
|
510
|
-
#
|
|
511
|
-
# @return [String] the normalized repository value (`'.'` when nil was given)
|
|
512
|
-
#
|
|
513
|
-
# @api private
|
|
514
|
-
#
|
|
515
|
-
def self.normalize_ls_remote_repository(repository)
|
|
516
|
-
return repository unless repository.nil?
|
|
517
|
-
|
|
518
|
-
Git::Deprecation.warn(
|
|
519
|
-
'Passing nil as the repository to Git.ls_remote is deprecated and will ' \
|
|
520
|
-
"be removed in v6.0.0. Pass '.' explicitly or omit the argument instead."
|
|
521
|
-
)
|
|
522
|
-
|
|
523
|
-
'.'
|
|
524
|
-
end
|
|
525
|
-
private_class_method :normalize_ls_remote_repository
|
|
526
|
-
|
|
527
355
|
# Thread-safe cache for git versions, keyed by binary path.
|
|
528
356
|
@git_version_cache_mutex = Mutex.new
|
|
529
357
|
@git_version_cache = {}
|
|
@@ -602,123 +430,6 @@ module Git
|
|
|
602
430
|
end
|
|
603
431
|
private_class_method :run_git_version
|
|
604
432
|
|
|
605
|
-
# Get or set a git config value
|
|
606
|
-
#
|
|
607
|
-
# @overload legacy_config_set_get_list(name, value, global:)
|
|
608
|
-
#
|
|
609
|
-
# Set the value of a git configuration option
|
|
610
|
-
#
|
|
611
|
-
# @param name [String] the name of the git configuration value to set
|
|
612
|
-
#
|
|
613
|
-
# @param value [String, Boolean] the value to set
|
|
614
|
-
#
|
|
615
|
-
# @param global [Boolean] true to use the global git configuration, false for the
|
|
616
|
-
# local repo config
|
|
617
|
-
#
|
|
618
|
-
# @return [Git::CommandLine::Result] the result of the git config command
|
|
619
|
-
#
|
|
620
|
-
# @overload legacy_config_set_get_list(name, global:)
|
|
621
|
-
#
|
|
622
|
-
# Get the value of a git configuration option
|
|
623
|
-
#
|
|
624
|
-
# @param name [String] the name of the git configuration value to get
|
|
625
|
-
#
|
|
626
|
-
# @param global [Boolean] true to use the global git configuration, false for the
|
|
627
|
-
# local repo config
|
|
628
|
-
#
|
|
629
|
-
# @return [String] the value of the git configuration option
|
|
630
|
-
#
|
|
631
|
-
# @overload legacy_config_set_get_list(global:)
|
|
632
|
-
#
|
|
633
|
-
# Get all git configuration options
|
|
634
|
-
#
|
|
635
|
-
# @param global [Boolean] true to use the global git configuration, false for the
|
|
636
|
-
# local repo config
|
|
637
|
-
#
|
|
638
|
-
# @return [Hash{String => String}] all git configuration options
|
|
639
|
-
#
|
|
640
|
-
# @raise [Git::FailedError] if the git config command fails
|
|
641
|
-
#
|
|
642
|
-
# @api private
|
|
643
|
-
#
|
|
644
|
-
def self.legacy_config_set_get_list(name, value, global:)
|
|
645
|
-
if !name.nil? && !value.nil?
|
|
646
|
-
legacy_config_set(name, value, global:)
|
|
647
|
-
elsif !name.nil?
|
|
648
|
-
legacy_config_get(name, global:)
|
|
649
|
-
else
|
|
650
|
-
legacy_config_list(global:)
|
|
651
|
-
end
|
|
652
|
-
end
|
|
653
|
-
private_class_method :legacy_config_set_get_list
|
|
654
|
-
|
|
655
|
-
# Set the value of a git configuration option
|
|
656
|
-
#
|
|
657
|
-
# @param name [String] the name of the git configuration value to set
|
|
658
|
-
#
|
|
659
|
-
# @param value [String, Boolean] the value to set
|
|
660
|
-
#
|
|
661
|
-
# @param global [Boolean] whether to use the global git configuration
|
|
662
|
-
#
|
|
663
|
-
# @api private
|
|
664
|
-
#
|
|
665
|
-
def self.legacy_config_set(name, value, global:)
|
|
666
|
-
options = global ? { global: true } : {}
|
|
667
|
-
Git::Commands::ConfigOptionSyntax::Set.new(execution_context).call(name, value, **options)
|
|
668
|
-
end
|
|
669
|
-
private_class_method :legacy_config_set
|
|
670
|
-
|
|
671
|
-
# Get the value of a git configuration option
|
|
672
|
-
#
|
|
673
|
-
# @param name [String] the name of the git configuration option
|
|
674
|
-
#
|
|
675
|
-
# @param global [Boolean] whether to use the global git configuration
|
|
676
|
-
#
|
|
677
|
-
# @return [String] the value of the git configuration option
|
|
678
|
-
#
|
|
679
|
-
# @api private
|
|
680
|
-
#
|
|
681
|
-
def self.legacy_config_get(name, global:)
|
|
682
|
-
options = global ? { global: true } : {}
|
|
683
|
-
result = Git::Commands::ConfigOptionSyntax::Get.new(execution_context).call(name, **options)
|
|
684
|
-
raise Git::FailedError, result if result.status.exitstatus != 0
|
|
685
|
-
|
|
686
|
-
result.stdout
|
|
687
|
-
end
|
|
688
|
-
private_class_method :legacy_config_get
|
|
689
|
-
|
|
690
|
-
# Get a list of all git configuration options
|
|
691
|
-
#
|
|
692
|
-
# @param global [Boolean] true to use the global git configuration, false for the
|
|
693
|
-
# local repo config
|
|
694
|
-
#
|
|
695
|
-
# @return [Hash{String => String}] all git configuration options
|
|
696
|
-
#
|
|
697
|
-
# @api private
|
|
698
|
-
#
|
|
699
|
-
def self.legacy_config_list(global:)
|
|
700
|
-
options = global ? { global: true } : {}
|
|
701
|
-
output = Git::Commands::ConfigOptionSyntax::List.new(execution_context).call(**options).stdout
|
|
702
|
-
parse_config_list(output.split("\n"))
|
|
703
|
-
end
|
|
704
|
-
private_class_method :legacy_config_list
|
|
705
|
-
|
|
706
|
-
# Parse the output of `git config --list` into a hash
|
|
707
|
-
#
|
|
708
|
-
# @param lines [Array<String>] the lines of output from `git config --list`
|
|
709
|
-
#
|
|
710
|
-
# @return [Hash{String => String}] the parsed git configuration options
|
|
711
|
-
#
|
|
712
|
-
# @api private
|
|
713
|
-
#
|
|
714
|
-
def self.parse_config_list(lines)
|
|
715
|
-
lines.each_with_object({}) do |line, hsh|
|
|
716
|
-
key, value = line.split('=', 2)
|
|
717
|
-
hsh[key] = value || ''
|
|
718
|
-
end
|
|
719
|
-
end
|
|
720
|
-
private_class_method :parse_config_list
|
|
721
|
-
|
|
722
433
|
# @api private
|
|
723
434
|
def self.execution_context
|
|
724
435
|
Git::ExecutionContext::Global.new
|
|
@@ -759,32 +470,4 @@ module Git
|
|
|
759
470
|
raise ArgumentError, "#{invalid.join(', ')} scope requires a repository"
|
|
760
471
|
end
|
|
761
472
|
private_class_method :assert_valid_scope!
|
|
762
|
-
|
|
763
|
-
# Return the version of the git binary
|
|
764
|
-
#
|
|
765
|
-
# @example Basic usage
|
|
766
|
-
# Git.binary_version # => [2, 46, 0]
|
|
767
|
-
#
|
|
768
|
-
# @param binary_path [String, nil] path to the git binary; defaults to
|
|
769
|
-
# `Git::Config.instance.binary_path`
|
|
770
|
-
#
|
|
771
|
-
# @return [Array<Integer>] the version of the git binary
|
|
772
|
-
#
|
|
773
|
-
# @deprecated Use {Git.git_version} instead, which returns a
|
|
774
|
-
# {Git::Version} (not an Array)
|
|
775
|
-
#
|
|
776
|
-
# For the legacy array shape, call: `Git.git_version.to_a`.
|
|
777
|
-
# The optional binary_path argument is preserved:
|
|
778
|
-
# `Git.git_version(binary_path)`.
|
|
779
|
-
#
|
|
780
|
-
def self.binary_version(binary_path = nil)
|
|
781
|
-
binary_path ||= Git::Config.instance.binary_path
|
|
782
|
-
Git::Deprecation.warn(
|
|
783
|
-
'Git.binary_version is deprecated and will be removed in v6.0.0. ' \
|
|
784
|
-
'Use Git.git_version instead, which returns a Git::Version ' \
|
|
785
|
-
'(not an Array). For the legacy array shape, call: Git.git_version.to_a. ' \
|
|
786
|
-
'The optional binary_path argument is preserved: Git.git_version(binary_path).'
|
|
787
|
-
)
|
|
788
|
-
git_version(binary_path).to_a
|
|
789
|
-
end
|
|
790
473
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Chacon and others
|
|
@@ -15,28 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 7.0.9
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 7.0.9
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: addressable
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '2.
|
|
32
|
+
version: '2.9'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '2.
|
|
39
|
+
version: '2.9'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: logger
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '1.6'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '1.6'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: process_executer
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -310,13 +324,10 @@ files:
|
|
|
310
324
|
- UPGRADING.md
|
|
311
325
|
- git.gemspec
|
|
312
326
|
- lib/git.rb
|
|
313
|
-
- lib/git/author.rb
|
|
314
327
|
- lib/git/author_info.rb
|
|
315
|
-
- lib/git/branch.rb
|
|
316
328
|
- lib/git/branch_delete_failure.rb
|
|
317
329
|
- lib/git/branch_delete_result.rb
|
|
318
330
|
- lib/git/branch_info.rb
|
|
319
|
-
- lib/git/branches.rb
|
|
320
331
|
- lib/git/command_line.rb
|
|
321
332
|
- lib/git/command_line/base.rb
|
|
322
333
|
- lib/git/command_line/capturing.rb
|
|
@@ -509,7 +520,6 @@ files:
|
|
|
509
520
|
- lib/git/parsers/tag.rb
|
|
510
521
|
- lib/git/parsers/worktree.rb
|
|
511
522
|
- lib/git/path_resolver.rb
|
|
512
|
-
- lib/git/remote.rb
|
|
513
523
|
- lib/git/remote_info.rb
|
|
514
524
|
- lib/git/repository.rb
|
|
515
525
|
- lib/git/repository/branching.rb
|
|
@@ -527,29 +537,25 @@ files:
|
|
|
527
537
|
- lib/git/repository/stashing.rb
|
|
528
538
|
- lib/git/repository/status_operations.rb
|
|
529
539
|
- lib/git/repository/worktree_operations.rb
|
|
530
|
-
- lib/git/stash.rb
|
|
531
540
|
- lib/git/stash_info.rb
|
|
532
|
-
- lib/git/stashes.rb
|
|
533
|
-
- lib/git/status.rb
|
|
534
541
|
- lib/git/status_file_info.rb
|
|
535
542
|
- lib/git/status_info.rb
|
|
543
|
+
- lib/git/system_call_guard.rb
|
|
536
544
|
- lib/git/tag_delete_failure.rb
|
|
537
545
|
- lib/git/tag_delete_result.rb
|
|
538
546
|
- lib/git/tag_info.rb
|
|
539
547
|
- lib/git/url.rb
|
|
540
548
|
- lib/git/version.rb
|
|
541
549
|
- lib/git/version_constraint.rb
|
|
542
|
-
- lib/git/worktree.rb
|
|
543
550
|
- lib/git/worktree_info.rb
|
|
544
|
-
- lib/git/worktrees.rb
|
|
545
551
|
homepage: http://github.com/ruby-git/ruby-git
|
|
546
552
|
licenses:
|
|
547
553
|
- MIT
|
|
548
554
|
metadata:
|
|
549
555
|
homepage_uri: http://github.com/ruby-git/ruby-git
|
|
550
556
|
source_code_uri: http://github.com/ruby-git/ruby-git
|
|
551
|
-
changelog_uri: https://rubydoc.info/gems/git/
|
|
552
|
-
documentation_uri: https://rubydoc.info/gems/git/
|
|
557
|
+
changelog_uri: https://rubydoc.info/gems/git/6.0.0/file/CHANGELOG.md
|
|
558
|
+
documentation_uri: https://rubydoc.info/gems/git/6.0.0
|
|
553
559
|
rubygems_mfa_required: 'true'
|
|
554
560
|
rdoc_options: []
|
|
555
561
|
require_paths:
|
|
@@ -558,14 +564,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
558
564
|
requirements:
|
|
559
565
|
- - ">="
|
|
560
566
|
- !ruby/object:Gem::Version
|
|
561
|
-
version: 3.
|
|
567
|
+
version: 3.3.0
|
|
562
568
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
563
569
|
requirements:
|
|
564
570
|
- - ">="
|
|
565
571
|
- !ruby/object:Gem::Version
|
|
566
572
|
version: '0'
|
|
567
573
|
requirements:
|
|
568
|
-
- git 2.
|
|
574
|
+
- git 2.43.0 or greater
|
|
569
575
|
rubygems_version: 4.0.20
|
|
570
576
|
specification_version: 4
|
|
571
577
|
summary: An API to create, read, and manipulate Git repositories
|
data/lib/git/author.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Git
|
|
4
|
-
# An author in a Git commit
|
|
5
|
-
#
|
|
6
|
-
# @deprecated Use {Git::AuthorInfo} instead; this mutable class will be
|
|
7
|
-
# removed in v6.0.0
|
|
8
|
-
#
|
|
9
|
-
# @api public
|
|
10
|
-
#
|
|
11
|
-
class Author
|
|
12
|
-
# @return [String, nil] the author's name
|
|
13
|
-
attr_accessor :name
|
|
14
|
-
|
|
15
|
-
# @return [String, nil] the author's email
|
|
16
|
-
attr_accessor :email
|
|
17
|
-
|
|
18
|
-
# @return [Time, nil] the date the change was authored (author date, not committer date)
|
|
19
|
-
attr_accessor :date
|
|
20
|
-
|
|
21
|
-
# Initializes a new Author object from a string
|
|
22
|
-
#
|
|
23
|
-
# @example
|
|
24
|
-
# Git::Author.new("John Doe <john.doe@example.com> 1627849923 +0200")
|
|
25
|
-
#
|
|
26
|
-
# @param author_string [String] the author string
|
|
27
|
-
#
|
|
28
|
-
# @return [void]
|
|
29
|
-
#
|
|
30
|
-
# @deprecated Use {Git::AuthorInfo.parse} instead
|
|
31
|
-
#
|
|
32
|
-
def initialize(author_string)
|
|
33
|
-
if defined?(Git::Deprecation)
|
|
34
|
-
Git::Deprecation.warn(
|
|
35
|
-
'Git::Author is deprecated and will be removed in v6.0.0. Use Git::AuthorInfo instead.'
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
return unless (m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string))
|
|
40
|
-
|
|
41
|
-
@name = m[1]
|
|
42
|
-
@email = m[2]
|
|
43
|
-
@date = Time.at(m[3].to_i)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|