git 5.7.0 → 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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +132 -35
  3. data/CONTRIBUTING.md +44 -31
  4. data/README.md +138 -100
  5. data/UPGRADING.md +867 -262
  6. data/git.gemspec +6 -8
  7. data/lib/git/author_info.rb +1 -2
  8. data/lib/git/commands/base.rb +22 -2
  9. data/lib/git/commands/cat_file/raw.rb +0 -68
  10. data/lib/git/commands/maintenance/register.rb +0 -4
  11. data/lib/git/commands/maintenance/run.rb +0 -4
  12. data/lib/git/commands/maintenance/start.rb +0 -4
  13. data/lib/git/commands/maintenance/stop.rb +0 -4
  14. data/lib/git/commands/maintenance/unregister.rb +0 -4
  15. data/lib/git/commands/maintenance.rb +0 -2
  16. data/lib/git/commands/show_ref/exclude_existing.rb +1 -1
  17. data/lib/git/commands/show_ref/exists.rb +0 -5
  18. data/lib/git/commands/show_ref/list.rb +1 -1
  19. data/lib/git/commands/show_ref/verify.rb +1 -1
  20. data/lib/git/commands/show_ref.rb +1 -1
  21. data/lib/git/commands/worktree/repair.rb +0 -5
  22. data/lib/git/diff_path_status.rb +1 -1
  23. data/lib/git/encoding_utils.rb +25 -0
  24. data/lib/git/errors.rb +24 -18
  25. data/lib/git/factories.rb +361 -125
  26. data/lib/git/log.rb +3 -75
  27. data/lib/git/object.rb +4 -185
  28. data/lib/git/path_resolver.rb +104 -36
  29. data/lib/git/repository/branching.rb +21 -189
  30. data/lib/git/repository/committing.rb +0 -25
  31. data/lib/git/repository/context_helpers.rb +249 -155
  32. data/lib/git/repository/diffing.rb +2 -72
  33. data/lib/git/repository/merging.rb +32 -54
  34. data/lib/git/repository/object_operations.rb +120 -497
  35. data/lib/git/repository/remote_operations.rb +7 -219
  36. data/lib/git/repository/staging.rb +6 -184
  37. data/lib/git/repository/stashing.rb +126 -130
  38. data/lib/git/repository/status_operations.rb +1 -54
  39. data/lib/git/repository/worktree_operations.rb +30 -125
  40. data/lib/git/repository.rb +20 -299
  41. data/lib/git/system_call_guard.rb +95 -0
  42. data/lib/git/version.rb +1 -1
  43. data/lib/git.rb +47 -364
  44. metadata +24 -18
  45. data/lib/git/author.rb +0 -46
  46. data/lib/git/branch.rb +0 -693
  47. data/lib/git/branches.rb +0 -194
  48. data/lib/git/remote.rb +0 -191
  49. data/lib/git/stash.rb +0 -124
  50. data/lib/git/stashes.rb +0 -198
  51. data/lib/git/status.rb +0 -384
  52. data/lib/git/worktree.rb +0 -180
  53. data/lib/git/worktrees.rb +0 -152
data/git.gemspec CHANGED
@@ -38,11 +38,12 @@ Gem::Specification.new do |spec|
38
38
  spec.metadata['rubygems_mfa_required'] = 'true'
39
39
 
40
40
  spec.require_paths = ['lib']
41
- spec.required_ruby_version = '>= 3.2.0'
42
- spec.requirements = ['git 2.28.0 or greater']
41
+ spec.required_ruby_version = '>= 3.3.0'
42
+ spec.requirements = ['git 2.43.0 or greater']
43
43
 
44
- spec.add_dependency 'activesupport', '>= 5.0'
45
- spec.add_dependency 'addressable', '~> 2.8'
44
+ spec.add_dependency 'activesupport', '>= 7.0.9'
45
+ spec.add_dependency 'addressable', '~> 2.9'
46
+ spec.add_dependency 'logger', '~> 1.6'
46
47
  spec.add_dependency 'process_executer', '~> 4.1'
47
48
  spec.add_dependency 'rchardet', '~> 1.9'
48
49
 
@@ -74,9 +75,6 @@ Gem::Specification.new do |spec|
74
75
  # is also a C extension and so could not install on JRuby regardless.
75
76
  install_docs = mri
76
77
 
77
- # yard-lint requires Ruby >= 3.3.
78
- install_yard_lint = install_docs && Gem.ruby_version >= Gem::Version.new('3.3.0')
79
-
80
78
  # i18n 1.15+ uses Fiber.[] (Ruby 3.2 Fiber storage), which TruffleRuby < 34.0.0 does
81
79
  # not implement, so those runtimes hold at the last release that works there.
82
80
  pin_old_i18n = RUBY_ENGINE == 'truffleruby' &&
@@ -98,7 +96,7 @@ Gem::Specification.new do |spec|
98
96
  spec.add_development_dependency 'simplecov-rspec', '~> 1.1'
99
97
  spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28' if install_docs
100
98
  spec.add_development_dependency 'yard_example_test', '~> 0.2', '>= 0.2.1' if install_docs
101
- spec.add_development_dependency 'yard-lint', '~> 1.8' if install_yard_lint
99
+ spec.add_development_dependency 'yard-lint', '~> 1.8' if install_docs
102
100
 
103
101
  # Specify which files should be added to the gem when it is released.
104
102
  #
@@ -4,8 +4,7 @@ module Git
4
4
  # Immutable value object representing an author or committer identity
5
5
  #
6
6
  # This is a lightweight, immutable data structure holding the identity data
7
- # git records for commit authors, committers, and taggers. It replaces the
8
- # mutable {Git::Author}, which is deprecated.
7
+ # git records for commit authors, committers, and taggers.
9
8
  #
10
9
  # @example Construct from individual values
11
10
  # info = Git::AuthorInfo.new(
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'git/commands/arguments'
4
+ require 'git/system_call_guard'
4
5
  require 'git/version'
5
6
  require 'git/version_constraint'
6
7
 
@@ -451,6 +452,10 @@ module Git
451
452
  # Pass an empty string when the process should receive no input (e.g.
452
453
  # when `--batch-all-objects` is used and git enumerates objects itself).
453
454
  #
455
+ # Both ends of the pipe are closed by the time this method returns or
456
+ # raises, whether the failure happens in the block, in the writer thread,
457
+ # or before the writer thread can be started.
458
+ #
454
459
  # @example Feed bound object names to a git batch command
455
460
  # bound = args_definition.bind(*args, **kwargs)
456
461
  # stdin_content = Array(bound.object).map { |object| "#{object}\n" }.join
@@ -462,6 +467,13 @@ module Git
462
467
  #
463
468
  # @return [Object] the value returned by the block
464
469
  #
470
+ # @raise [Git::Error] if the pipe cannot be created (for example, when the
471
+ # process is out of file descriptors); the `SystemCallError` is the `cause`
472
+ #
473
+ # @raise [Git::Error] if the writer thread cannot be started (for example,
474
+ # when the process cannot allocate another thread); the `ThreadError` is
475
+ # the `cause`
476
+ #
465
477
  # @yield [reader] the read end of the pipe
466
478
  #
467
479
  # @yieldparam reader [IO] the read end of the pipe; valid only for the
@@ -470,11 +482,14 @@ module Git
470
482
  # @yieldreturn [Object] the block's return value, which becomes the method's return value
471
483
  #
472
484
  def with_stdin(content)
473
- reader, writer = IO.pipe
485
+ reader, writer = Git::SystemCallGuard.call('Failed to create a pipe for stdin') { IO.pipe }
474
486
  writer_thread = start_stdin_writer(content, writer)
475
487
  yield reader
476
488
  ensure
477
- reader.close unless reader.closed?
489
+ reader.close unless reader.nil? || reader.closed?
490
+ # The writer thread owns writer and closes it when it finishes. Close it
491
+ # here only when the thread was never started (Thread.new raised).
492
+ writer.close if writer_thread.nil? && !(writer.nil? || writer.closed?)
478
493
  writer_thread&.join
479
494
  end
480
495
 
@@ -488,6 +503,9 @@ module Git
488
503
  #
489
504
  # @return [Thread] thread writing content to the pipe
490
505
  #
506
+ # @raise [Git::Error] if the thread cannot be started; the `ThreadError` is
507
+ # the `cause`
508
+ #
491
509
  def start_stdin_writer(content, writer)
492
510
  Thread.new do
493
511
  writer.write(content) unless content.empty?
@@ -496,6 +514,8 @@ module Git
496
514
  ensure
497
515
  writer.close unless writer.closed?
498
516
  end
517
+ rescue ThreadError => e
518
+ raise Git::Error, "Failed to start the stdin writer thread: #{e.message}"
499
519
  end
500
520
  end
501
521
  end
@@ -49,14 +49,6 @@ module Git
49
49
  # See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt--s
50
50
  flag_option :s
51
51
 
52
- # Allow -t and -s to query broken or corrupt objects of unknown type.
53
- # Deprecated and removed in v6.0.0 (see issue 1709); passing it emits a
54
- # deprecation warning. Git 2.28-2.49 honors it with -t and -s and rejects
55
- # it in other modes; git 2.50+ accepts and ignores it everywhere (the
56
- # unknown-type feature was removed).
57
- # See https://git-scm.com/docs/git-cat-file/2.49.0#Documentation/git-cat-file.txt---allow-unknown-type
58
- flag_option :allow_unknown_type
59
-
60
52
  # Map committer/author identities through the mailmap before reporting size
61
53
  # See https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt---use-mailmap
62
54
  flag_option :use_mailmap, negatable: true
@@ -93,13 +85,6 @@ module Git
93
85
  #
94
86
  # @param options [Hash] command options
95
87
  #
96
- # @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
97
- # which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
98
- # on git 2.50 and later
99
- #
100
- # Deprecated and removed in v6.0.0; passing it emits a deprecation
101
- # warning.
102
- #
103
88
  # @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
104
89
  #
105
90
  # @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
@@ -121,13 +106,6 @@ module Git
121
106
  #
122
107
  # @param options [Hash] command options
123
108
  #
124
- # @option options [Boolean, nil] :allow_unknown_type (nil) allow querying broken or corrupt objects of
125
- # unknown type on git 2.28-2.49
126
- #
127
- # Deprecated and removed in v6.0.0; passing it emits a deprecation
128
- # warning. Git 2.50 removed the unknown-type feature and accepts this
129
- # flag as a no-op.
130
- #
131
109
  # @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
132
110
  #
133
111
  # @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
@@ -149,13 +127,6 @@ module Git
149
127
  #
150
128
  # @param options [Hash] command options
151
129
  #
152
- # @option options [Boolean, nil] :allow_unknown_type (nil) allow querying broken or corrupt objects of
153
- # unknown type on git 2.28-2.49
154
- #
155
- # Deprecated and removed in v6.0.0; passing it emits a deprecation
156
- # warning. Git 2.50 removed the unknown-type feature and accepts this
157
- # flag as a no-op.
158
- #
159
130
  # @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
160
131
  #
161
132
  # @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
@@ -177,13 +148,6 @@ module Git
177
148
  #
178
149
  # @param options [Hash] command options
179
150
  #
180
- # @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
181
- # which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
182
- # on git 2.50 and later
183
- #
184
- # Deprecated and removed in v6.0.0; passing it emits a deprecation
185
- # warning.
186
- #
187
151
  # @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
188
152
  #
189
153
  # @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
@@ -205,13 +169,6 @@ module Git
205
169
  #
206
170
  # @param options [Hash] command options
207
171
  #
208
- # @option options [Boolean, nil] :allow_unknown_type (nil) pass `--allow-unknown-type` through to git,
209
- # which rejects it in this mode on git 2.28-2.49 and accepts it as a no-op
210
- # on git 2.50 and later
211
- #
212
- # Deprecated and removed in v6.0.0; passing it emits a deprecation
213
- # warning.
214
- #
215
172
  # @option options [Boolean, nil] :use_mailmap (nil) remap identities via mailmap (`--use-mailmap`)
216
173
  #
217
174
  # @option options [Boolean, nil] :no_use_mailmap (nil) suppress mailmap remapping (`--no-use-mailmap`)
@@ -228,7 +185,6 @@ module Git
228
185
  # @option options [Numeric, nil] :timeout (nil) abort the command after this many seconds
229
186
  #
230
187
  def call(*, **)
231
- warn_allow_unknown_type_deprecated(**)
232
188
  bound = args_definition.bind(*, **)
233
189
  validate_version!(bound.execution_options)
234
190
  result = execute_command(bound)
@@ -241,30 +197,6 @@ module Git
241
197
 
242
198
  result
243
199
  end
244
-
245
- private
246
-
247
- # Emit the deprecation warning when the `allow_unknown_type` keyword is passed
248
- #
249
- # Keys on the keyword being present, whatever its value: `false` and `nil`
250
- # suppress the flag but still name a deprecated option.
251
- #
252
- # @param options [Hash] the keyword arguments passed to {#call}
253
- #
254
- # @option options [Boolean, nil] :allow_unknown_type the deprecated option;
255
- # any value, including `false` and `nil`, triggers the warning
256
- #
257
- # @return [void]
258
- #
259
- def warn_allow_unknown_type_deprecated(**options)
260
- return unless options.key?(:allow_unknown_type)
261
-
262
- Git::Deprecation.warn(
263
- 'The allow_unknown_type option of Git::Commands::CatFile::Raw is deprecated ' \
264
- 'and will be removed in v6.0.0. Git 2.50 removed the unknown-type feature ' \
265
- 'and accepts --allow-unknown-type as a no-op.'
266
- )
267
- end
268
200
  end
269
201
  end
270
202
  end
@@ -22,8 +22,6 @@ module Git
22
22
  # @api private
23
23
  #
24
24
  class Register < Git::Commands::Base
25
- requires_git_version '2.30.0'
26
-
27
25
  arguments do
28
26
  literal 'maintenance'
29
27
  literal 'register'
@@ -65,8 +63,6 @@ module Git
65
63
  #
66
64
  # @raise [Git::FailedError] if git exits with a non-zero exit status
67
65
  #
68
- # @raise [Git::VersionError] if git version is below 2.30.0
69
- #
70
66
  # @api public
71
67
  def call(*, **)
72
68
  super
@@ -28,8 +28,6 @@ module Git
28
28
  # @api private
29
29
  #
30
30
  class Run < Git::Commands::Base
31
- requires_git_version '2.30.0'
32
-
33
31
  arguments do
34
32
  literal 'maintenance'
35
33
  literal 'run'
@@ -100,8 +98,6 @@ module Git
100
98
  #
101
99
  # @raise [Git::FailedError] if git exits with a non-zero exit status
102
100
  #
103
- # @raise [Git::VersionError] if git version is below 2.30.0
104
- #
105
101
  # @api public
106
102
  end
107
103
  end
@@ -22,8 +22,6 @@ module Git
22
22
  # @api private
23
23
  #
24
24
  class Start < Git::Commands::Base
25
- requires_git_version '2.30.0'
26
-
27
25
  arguments do
28
26
  literal 'maintenance'
29
27
  literal 'start'
@@ -63,8 +61,6 @@ module Git
63
61
  # @raise [ArgumentError] if unsupported options are provided
64
62
  #
65
63
  # @raise [Git::FailedError] if git exits with a non-zero exit status
66
- #
67
- # @raise [Git::VersionError] if git version is below 2.30.0
68
64
  end
69
65
  end
70
66
  end
@@ -19,8 +19,6 @@ module Git
19
19
  # @api private
20
20
  #
21
21
  class Stop < Git::Commands::Base
22
- requires_git_version '2.30.0'
23
-
24
22
  arguments do
25
23
  literal 'maintenance'
26
24
  literal 'stop'
@@ -52,8 +50,6 @@ module Git
52
50
  # @raise [ArgumentError] if unsupported options are provided
53
51
  #
54
52
  # @raise [Git::FailedError] if git exits with a non-zero exit status
55
- #
56
- # @raise [Git::VersionError] if git version is below 2.30.0
57
53
  end
58
54
  end
59
55
  end
@@ -22,8 +22,6 @@ module Git
22
22
  # @api private
23
23
  #
24
24
  class Unregister < Git::Commands::Base
25
- requires_git_version '2.30.0'
26
-
27
25
  arguments do
28
26
  literal 'maintenance'
29
27
  literal 'unregister'
@@ -75,8 +73,6 @@ module Git
75
73
  #
76
74
  # @raise [Git::FailedError] if git exits with a non-zero exit status
77
75
  #
78
- # @raise [Git::VersionError] if git version is below 2.30.0
79
- #
80
76
  # @api public
81
77
  end
82
78
  end
@@ -19,8 +19,6 @@ module Git
19
19
  # - {Maintenance::Register} — add repository to maintenance config
20
20
  # - {Maintenance::Unregister} — remove repository from maintenance config
21
21
  #
22
- # All subcommands require Git 2.30.0 or later.
23
- #
24
22
  # @see https://git-scm.com/docs/git-maintenance git-maintenance documentation
25
23
  #
26
24
  # @api private
@@ -16,7 +16,7 @@ module Git
16
16
  #
17
17
  # For standard ref listing, use {Git::Commands::ShowRef::List}.
18
18
  # For strict per-ref verification, use {Git::Commands::ShowRef::Verify}.
19
- # For a boolean existence check (git >= 2.43), use {Git::Commands::ShowRef::Exists}.
19
+ # For a boolean existence check, use {Git::Commands::ShowRef::Exists}.
20
20
  #
21
21
  # @example Filter refs that do not exist locally
22
22
  # cmd = Git::Commands::ShowRef::ExcludeExisting.new(execution_context)
@@ -25,11 +25,6 @@ module Git
25
25
  # result = cmd.call('refs/heads/main')
26
26
  # result.status.exitstatus # => 0 (exists) or 2 (not found)
27
27
  #
28
- # @note Requires git 2.43 or later
29
- #
30
- # Earlier versions do not recognise the `--exists` flag and will exit
31
- # non-zero with an "unknown option" error.
32
- #
33
28
  # @note `arguments` block audited against https://git-scm.com/docs/git-show-ref/2.53.0
34
29
  #
35
30
  # @see Git::Commands::ShowRef
@@ -16,7 +16,7 @@ module Git
16
16
  #
17
17
  # For strict per-ref verification, use {Git::Commands::ShowRef::Verify}.
18
18
  # For stdin-based filtering, use {Git::Commands::ShowRef::ExcludeExisting}.
19
- # For a simple boolean existence check (git >= 2.43), use {Git::Commands::ShowRef::Exists}.
19
+ # For a simple boolean existence check, use {Git::Commands::ShowRef::Exists}.
20
20
  #
21
21
  # @example List all refs
22
22
  # cmd = Git::Commands::ShowRef::List.new(execution_context)
@@ -18,7 +18,7 @@ module Git
18
18
  #
19
19
  # For pattern-based listing, use {ShowRef::List}.
20
20
  # For stdin-based filtering, use {ShowRef::ExcludeExisting}.
21
- # For a silent boolean check (git >= 2.43), use {ShowRef::Exists}.
21
+ # For a silent boolean check, use {ShowRef::Exists}.
22
22
  #
23
23
  # @example Verify a single ref
24
24
  # cmd = Git::Commands::ShowRef::Verify.new(execution_context)
@@ -18,7 +18,7 @@ module Git
18
18
  # - {ShowRef::ExcludeExisting} — stdin-based filter for ref names, excluding
19
19
  # refs that already exist in the repository
20
20
  # (`git show-ref --exclude-existing[=<pattern>]`)
21
- # - {ShowRef::Exists} — boolean existence check without output (git >= 2.43)
21
+ # - {ShowRef::Exists} — boolean existence check without output
22
22
  # (`git show-ref --exists <ref>`)
23
23
  #
24
24
  # @example List all refs matching a pattern
@@ -34,9 +34,6 @@ module Git
34
34
  operand :path, repeatable: true
35
35
  end
36
36
 
37
- # git worktree repair was introduced in git 2.29.0
38
- requires_git_version '2.29.0'
39
-
40
37
  # @!method call(*)
41
38
  #
42
39
  # @overload call(*path, **options)
@@ -67,8 +64,6 @@ module Git
67
64
  #
68
65
  # @raise [Git::FailedError] if git exits with a non-zero exit status
69
66
  #
70
- # @raise [Git::VersionError] if git version is below 2.29.0
71
- #
72
67
  # @api public
73
68
  end
74
69
  end
@@ -72,7 +72,7 @@ module Git
72
72
 
73
73
  private
74
74
 
75
- # Lazily fetches and caches the path status from the git lib
75
+ # Lazily fetches and caches the path status from the repository
76
76
  #
77
77
  # @return [Hash{String => String}] a mapping of file paths to status codes
78
78
  #
@@ -48,6 +48,13 @@ module Git
48
48
 
49
49
  # Returns the given string converted to {Git::EncodingUtils.default_encoding}
50
50
  #
51
+ # When the string is not valid in its own encoding, the source encoding is
52
+ # taken from {Git::EncodingUtils.detected_encoding}. rchardet can name an
53
+ # encoding Ruby has no converter for (`UTF-7` and the two unusual-octet-order
54
+ # `UCS-4` forms, each assigned from a byte-order mark). In that case the
55
+ # invalid bytes are replaced with `String#scrub` instead, which keeps any
56
+ # valid multibyte sequences on the same line.
57
+ #
51
58
  # @param str [String] the string to normalize
52
59
  #
53
60
  # @return [String] the original or transcoded string in
@@ -59,6 +66,24 @@ module Git
59
66
  return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding?
60
67
 
61
68
  str.encode(default_encoding, detected_encoding(str), **encoding_options)
69
+ rescue Encoding::ConverterNotFoundError
70
+ scrub_to_default_encoding(str)
71
+ end
72
+
73
+ # Returns the given string with its invalid bytes replaced, in
74
+ # {Git::EncodingUtils.default_encoding}
75
+ #
76
+ # `String#scrub` returns the string in its own encoding, so the result is
77
+ # transcoded afterward. On the gem's own call path the string is already
78
+ # tagged UTF-8 and that step is a no-op.
79
+ #
80
+ # @param str [String] the string to scrub
81
+ #
82
+ # @return [String] the scrubbed string in {Git::EncodingUtils.default_encoding}
83
+ #
84
+ def self.scrub_to_default_encoding(str)
85
+ str.scrub.encode(default_encoding, **encoding_options)
62
86
  end
87
+ private_class_method :scrub_to_default_encoding
63
88
  end
64
89
  end
data/lib/git/errors.rb CHANGED
@@ -5,24 +5,22 @@ module Git
5
5
 
6
6
  # Base class for all custom git module errors
7
7
  #
8
- # Errors the git gem raises deliberately are either `ArgumentError` or a subclass
9
- # of `Git::Error`. The exceptions described below come from Ruby's standard
10
- # library and are not converted.
11
- #
12
- # The gem's own filesystem operations, such as reading a `.git` pointer file,
13
- # creating a temporary file, or changing directory, do not convert operating
14
- # system errors. These can be raised as a bare `SystemCallError` (for example
15
- # `Errno::ENOENT` or `Errno::EACCES`) rather than `Git::Error`. Gzip compression
16
- # in `archive` can likewise raise a `Zlib::Error`. Rescue `SystemCallError` and
17
- # `Zlib::Error` alongside `Git::Error` if your code needs to handle them. Any
18
- # method that captures git output can also raise
19
- # `Encoding::ConverterNotFoundError` when a line's detected encoding has no Ruby
20
- # converter. See the "Errors raised by this gem" section of the README for the
21
- # affected methods.
8
+ # The git gem will only raise an `ArgumentError` or an error that is a subclass of
9
+ # `Git::Error`.
22
10
  #
23
11
  # It is recommended to rescue `Git::Error` to catch any runtime error raised by
24
12
  # this gem unless you need more specific error handling.
25
13
  #
14
+ # Operating system errors from the gem's own filesystem operations, such as
15
+ # reading a `.git` pointer file or creating a temporary file, are raised as
16
+ # `Git::Error`. The original `SystemCallError` is available through `cause`.
17
+ #
18
+ # The promise covers errors the gem raises from its own operations. An error
19
+ # raised by a block your code passes to a method such as `chdir` propagates
20
+ # unchanged, and when `Git::Deprecation.behavior` is `:raise` a deprecated call
21
+ # raises `ActiveSupport::DeprecationException`, which is intentionally not a
22
+ # `Git::Error`.
23
+ #
26
24
  # Git's custom errors are arranged in the following class heirarchy:
27
25
  #
28
26
  # ```text
@@ -87,12 +85,20 @@ module Git
87
85
 
88
86
  # An alias for Git::Error
89
87
  #
90
- # Git::GitExecuteError error class is an alias for Git::Error for backwards
91
- # compatibility. It is recommended to use Git::Error directly.
88
+ # Git::GitExecuteError is an alias for Git::Error kept for backwards
89
+ # compatibility. It is an ActiveSupport::Deprecation::DeprecatedConstantProxy,
90
+ # so any use of it, including instantiating it and matching it in a `rescue`
91
+ # clause, emits a deprecation warning through Git::Deprecation. The
92
+ # reflective methods that debuggers and IRB call, such as `inspect` and
93
+ # `name`, do not warn. It will be removed in a future major release.
92
94
  #
93
- # @deprecated Use Git::Error instead
95
+ # @deprecated Use Git::Error instead. Will be removed in a future major release.
94
96
  #
95
- GitExecuteError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Git::GitExecuteError', 'Git::Error', Git::Deprecation)
97
+ GitExecuteError = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
98
+ 'Git::GitExecuteError', 'Git::Error', Git::Deprecation,
99
+ message: 'Git::GitExecuteError is deprecated and will be removed in a future major release. ' \
100
+ 'Use Git::Error instead.'
101
+ )
96
102
 
97
103
  # Raised when a git command fails or exits because of an uncaught signal
98
104
  #