ruby_git 0.3.3 → 0.3.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/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +13 -0
- data/lib/ruby_git/command_line/runner.rb +26 -7
- data/lib/ruby_git/errors.rb +8 -0
- data/lib/ruby_git/option_validators.rb +37 -0
- data/lib/ruby_git/version.rb +1 -1
- data/lib/ruby_git/worktree.rb +13 -20
- data/lib/ruby_git.rb +6 -4
- data/release-please-config.json +3 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c3507b566d30abc32d770188184bf932f3af97985f579df84dfa24b3e6e9a96
|
4
|
+
data.tar.gz: 8fecb84e47a289736ecf79579a2de496b0520734a4a3d6199c5838e0543ba1d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c39128ee93c9a24cb6b07f7b99284f2373647c02d276aa76e9ccad9bfa3ce622ed12c7e0d0043bb3e4b4834069db626de9cc4885ec25fd89a8bac86b705bcc
|
7
|
+
data.tar.gz: bc37e79e11cead6979605727b5134fbbd528610977768bb7302c79cb7eebf7fa385ce1b07573d208f1ff7e4af29344a30e2ddf9e1a9c66a38d60330253b79271
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [0.3.4](https://github.com/main-branch/ruby_git/compare/v0.3.3...v0.3.4) (2025-04-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Add initial_branch option to RubyGit::Worktree.init ([9f5e8da](https://github.com/main-branch/ruby_git/commit/9f5e8daca1599d46c9a53429b24f4fff47f148b6))
|
9
|
+
* Add initial_branch option to RubyGit.init ([c0007e5](https://github.com/main-branch/ruby_git/commit/c0007e501c2768e921c1aef618c8edb4969e5e95))
|
10
|
+
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
* Rewrap any errors raised by Process.spawn in RubyGit::SpawnError ([1ed4444](https://github.com/main-branch/ruby_git/commit/1ed4444c12ff1598af8915eac0c568bbaa865c84))
|
15
|
+
|
3
16
|
## [0.3.3](https://github.com/main-branch/ruby_git/compare/v0.3.2...v0.3.3) (2025-04-17)
|
4
17
|
|
5
18
|
|
@@ -187,20 +187,39 @@ module RubyGit
|
|
187
187
|
#
|
188
188
|
# @api private
|
189
189
|
#
|
190
|
-
def run_with_chdir(args, options)
|
191
|
-
return
|
190
|
+
def run_with_chdir(args, options) # rubocop:disable Metrics/MethodLength
|
191
|
+
return run_and_handle_spawn_error(args, options) unless jruby? && options.chdir != :not_set
|
192
192
|
|
193
193
|
# :nocov: Not executed in MRI Ruby
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
options.
|
194
|
+
begin
|
195
|
+
Dir.chdir(options.chdir) do
|
196
|
+
saved_chdir = options.chdir
|
197
|
+
options.merge!(chdir: :not_set)
|
198
|
+
run_and_handle_spawn_error(args, options).tap do
|
199
|
+
options.merge!(chdir: saved_chdir)
|
200
|
+
end
|
199
201
|
end
|
202
|
+
rescue Errno::ENOENT, Errno::ENOTDIR => e
|
203
|
+
raise RubyGit::SpawnError, "chdir(#{options.chdir}) failed: #{e.message}"
|
200
204
|
end
|
201
205
|
# :nocov:
|
202
206
|
end
|
203
207
|
|
208
|
+
# Catch ProcessExecuter::SpawnError and raise a RubyGit::SpawnError in its place
|
209
|
+
#
|
210
|
+
# @param args [Array<String>] the command to run
|
211
|
+
# @param options [RubyGit::CommandLine::Options] the options to pass to `Process.spawn`
|
212
|
+
#
|
213
|
+
# @return [ProcessExecuter::Result] the result of the command
|
214
|
+
#
|
215
|
+
# @api private
|
216
|
+
#
|
217
|
+
def run_and_handle_spawn_error(args, options)
|
218
|
+
ProcessExecuter.run_with_options(args, options)
|
219
|
+
rescue ProcessExecuter::SpawnError => e
|
220
|
+
raise RubyGit::SpawnError, e.message
|
221
|
+
end
|
222
|
+
|
204
223
|
# Returns true if running on JRuby
|
205
224
|
#
|
206
225
|
# @return [Boolean]
|
data/lib/ruby_git/errors.rb
CHANGED
@@ -21,6 +21,7 @@ module RubyGit
|
|
21
21
|
# │ └─> RubyGit::SignaledError
|
22
22
|
# │ └─> RubyGit::TimeoutError
|
23
23
|
# ├─> RubyGit::ProcessIOError
|
24
|
+
# ├─> RubyGit::SpawnError
|
24
25
|
# └─> RubyGit::UnexpectedResultError
|
25
26
|
# ```
|
26
27
|
#
|
@@ -32,6 +33,7 @@ module RubyGit
|
|
32
33
|
# | `SignaledError` | This error is raised when the git command line is terminated as a result of receiving a signal. This could happen if the process is forcibly terminated or if there is a serious system error. |
|
33
34
|
# | `TimeoutError` | This is a specific type of `SignaledError` that is raised when the git command line operation times out and is killed via the SIGKILL signal. This happens if the operation takes longer than the timeout duration configured in `Git.config.timeout` or via the `:timeout` parameter given in git methods that support timeouts. |
|
34
35
|
# | `ProcessIOError` | An error was encountered reading or writing to a subprocess. |
|
36
|
+
# | `SpawnError` | An error was encountered when spawning a subprocess and it never started. |
|
35
37
|
# | `UnexpectedResultError` | The command line ran without error but did not return the expected results. |
|
36
38
|
#
|
37
39
|
# @example Rescuing a generic error
|
@@ -166,4 +168,10 @@ module RubyGit
|
|
166
168
|
# @api public
|
167
169
|
#
|
168
170
|
class UnexpectedResultError < RubyGit::Error; end
|
171
|
+
|
172
|
+
# Raised when the git command could not be spawned
|
173
|
+
#
|
174
|
+
# @api public
|
175
|
+
#
|
176
|
+
class SpawnError < RubyGit::Error; end
|
169
177
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyGit
|
4
|
+
# Module containing option validators for RubyGit
|
5
|
+
# @api public
|
6
|
+
module OptionValidators
|
7
|
+
# Raise an error if an option is not a Boolean (or optionally nil) value
|
8
|
+
# @param name [String] the name of the option
|
9
|
+
# @param value [Object] the value of the option
|
10
|
+
# @param nullable [Boolean] whether the option can be nil (default is false)
|
11
|
+
# @return [void]
|
12
|
+
# @raise [ArgumentError] if the option is not a Boolean (or optionally nil) value
|
13
|
+
# @api private
|
14
|
+
def validate_boolean_option(name:, value:, nullable: false)
|
15
|
+
return if nullable && value.nil?
|
16
|
+
|
17
|
+
return if [true, false].include?(value)
|
18
|
+
|
19
|
+
raise ArgumentError, "The '#{name}:' option must be a Boolean value but was #{value.inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Raise an error if an option is not a String (or optionally nil) value
|
23
|
+
# @param name [String] the name of the option
|
24
|
+
# @param value [Object] the value of the option
|
25
|
+
# @param nullable [Boolean] whether the option can be nil (default is false)
|
26
|
+
# @return [void]
|
27
|
+
# @raise [ArgumentError] if the option is not a String (or optionally nil) value
|
28
|
+
# @api private
|
29
|
+
def validate_string_option(name:, value:, nullable: false)
|
30
|
+
return if nullable && value.nil?
|
31
|
+
|
32
|
+
return if value.is_a?(String)
|
33
|
+
|
34
|
+
raise ArgumentError, "The '#{name}:' option must be a String or nil but was #{value.inspect}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ruby_git/version.rb
CHANGED
data/lib/ruby_git/worktree.rb
CHANGED
@@ -7,6 +7,9 @@ module RubyGit
|
|
7
7
|
# Create a new Worktree using {.init}, {.clone}, or {.open}.
|
8
8
|
#
|
9
9
|
class Worktree
|
10
|
+
extend RubyGit::OptionValidators
|
11
|
+
include RubyGit::OptionValidators
|
12
|
+
|
10
13
|
# The root path of the working tree
|
11
14
|
#
|
12
15
|
# @example
|
@@ -26,19 +29,24 @@ module RubyGit
|
|
26
29
|
# @see https://git-scm.com/docs/git-init git-init
|
27
30
|
#
|
28
31
|
# @example
|
29
|
-
# worktree = Worktree.init(worktree_path)
|
32
|
+
# worktree = Worktree.init(worktree_path, initial_branch: 'main')
|
30
33
|
#
|
31
|
-
# @param [String]
|
34
|
+
# @param worktree_path [String] the root path of a Git working tree
|
35
|
+
# @param initial_branch [String] the initial branch in the newly created repository
|
32
36
|
#
|
33
|
-
# @raise [
|
37
|
+
# @raise [ArgumentError] if worktree_path does not exist or is not a directory
|
38
|
+
# @raise [RubyGit::Error] if there is an error initializing the repository
|
34
39
|
#
|
35
40
|
# @return [RubyGit::Worktree] the working tree whose root is at `path`
|
36
41
|
#
|
37
|
-
def self.init(worktree_path)
|
38
|
-
|
42
|
+
def self.init(worktree_path, initial_branch: nil)
|
43
|
+
validate_string_option(name: :initial_branch, value: initial_branch, nullable: true)
|
39
44
|
|
40
45
|
command = ['init']
|
46
|
+
command << '--initial-branch' << initial_branch unless initial_branch.nil?
|
47
|
+
|
41
48
|
options = { chdir: worktree_path, out: StringIO.new, err: StringIO.new }
|
49
|
+
|
42
50
|
RubyGit::CommandLine.run(*command, **options)
|
43
51
|
|
44
52
|
new(worktree_path)
|
@@ -300,20 +308,5 @@ module RubyGit
|
|
300
308
|
def run_with_context(*command, **options)
|
301
309
|
RubyGit::CommandLine.run(*command, repository_path: repository.path, worktree_path: path, **options)
|
302
310
|
end
|
303
|
-
|
304
|
-
# Raise an error if an option is not a Boolean (or optionally nil) value
|
305
|
-
# @param name [String] the name of the option
|
306
|
-
# @param value [Object] the value of the option
|
307
|
-
# @param nullable [Boolean] whether the option can be nil (default is false)
|
308
|
-
# @return [void]
|
309
|
-
# @raise [ArgumentError] if the option is not a Boolean (or optionally nil) value
|
310
|
-
# @api private
|
311
|
-
def validate_boolean_option(name:, value:, nullable: false)
|
312
|
-
return if nullable && value.nil?
|
313
|
-
|
314
|
-
return if [true, false].include?(value)
|
315
|
-
|
316
|
-
raise ArgumentError, "The '#{name}:' option must be a Boolean value but was #{value.inspect}"
|
317
|
-
end
|
318
311
|
end
|
319
312
|
end
|
data/lib/ruby_git.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'ruby_git/command_line'
|
4
4
|
require_relative 'ruby_git/encoding_normalizer'
|
5
5
|
require_relative 'ruby_git/errors'
|
6
|
+
require_relative 'ruby_git/option_validators'
|
6
7
|
require_relative 'ruby_git/repository'
|
7
8
|
require_relative 'ruby_git/status'
|
8
9
|
require_relative 'ruby_git/version'
|
@@ -79,16 +80,17 @@ module RubyGit
|
|
79
80
|
# @see https://git-scm.com/docs/git-init git-init
|
80
81
|
#
|
81
82
|
# @example
|
82
|
-
# worktree = Worktree.init(worktree_path)
|
83
|
+
# worktree = Worktree.init(worktree_path, initial_branch: 'main')
|
83
84
|
#
|
84
|
-
# @param [String]
|
85
|
+
# @param worktree_path [String] the root path of a worktree
|
86
|
+
# @param initial_branch [String] the initial branch in the newly created repository
|
85
87
|
#
|
86
88
|
# @raise [RubyGit::Error] if worktree_path is not a directory
|
87
89
|
#
|
88
90
|
# @return [RubyGit::Worktree] the worktree whose root is at `path`
|
89
91
|
#
|
90
|
-
def self.init(worktree_path)
|
91
|
-
RubyGit::Worktree.init(worktree_path)
|
92
|
+
def self.init(worktree_path, initial_branch:)
|
93
|
+
RubyGit::Worktree.init(worktree_path, initial_branch:)
|
92
94
|
end
|
93
95
|
|
94
96
|
# Open an existing Git working tree that contains worktree_path
|
data/release-please-config.json
CHANGED
@@ -8,9 +8,10 @@
|
|
8
8
|
"version-file": "lib/ruby_git/version.rb",
|
9
9
|
"bump-minor-pre-major": true,
|
10
10
|
"bump-patch-for-minor-pre-major": true,
|
11
|
-
"draft":
|
11
|
+
"draft": true,
|
12
12
|
"prerelease": false,
|
13
|
-
"include-component-in-tag": false
|
13
|
+
"include-component-in-tag": false,
|
14
|
+
"pull-request-title-pattern": "chore: release v${version}"
|
14
15
|
}
|
15
16
|
},
|
16
17
|
"plugins": [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Couball
|
@@ -268,6 +268,7 @@ files:
|
|
268
268
|
- lib/ruby_git/command_line/runner.rb
|
269
269
|
- lib/ruby_git/encoding_normalizer.rb
|
270
270
|
- lib/ruby_git/errors.rb
|
271
|
+
- lib/ruby_git/option_validators.rb
|
271
272
|
- lib/ruby_git/repository.rb
|
272
273
|
- lib/ruby_git/status.rb
|
273
274
|
- lib/ruby_git/status/branch.rb
|
@@ -294,8 +295,8 @@ metadata:
|
|
294
295
|
allowed_push_host: https://rubygems.org
|
295
296
|
homepage_uri: https://github.com/main-branch/ruby_git
|
296
297
|
source_code_uri: https://github.com/main-branch/ruby_git
|
297
|
-
documentation_uri: https://rubydoc.info/gems/ruby_git/0.3.
|
298
|
-
changelog_uri: https://rubydoc.info/gems/ruby_git/0.3.
|
298
|
+
documentation_uri: https://rubydoc.info/gems/ruby_git/0.3.4
|
299
|
+
changelog_uri: https://rubydoc.info/gems/ruby_git/0.3.4/file/CHANGELOG.md
|
299
300
|
rubygems_mfa_required: 'true'
|
300
301
|
rdoc_options: []
|
301
302
|
require_paths:
|