git 1.11.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/continuous_integration.yml +4 -0
- data/CHANGELOG.md +14 -1
- data/Gemfile +3 -2
- data/MAINTAINERS.md +2 -3
- data/README.md +18 -3
- data/git.gemspec +2 -1
- data/lib/git/base.rb +8 -4
- data/lib/git/lib.rb +37 -9
- data/lib/git/url.rb +127 -0
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +19 -9
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df0d52946aa19627fbff62a47b86f694763e957e1f6d87b9a5e14e6cae46ff1d
|
4
|
+
data.tar.gz: f2b9e31a9cfb944da55c25b22b54aacd54d788e77ef2808d7cfba0a466cedb8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a812bbdc6aabf7c63d30f96659edfe4a65a141dce613046d3f7e537f5105a80e48f6ae03cb30c4d806243cfd130b49bbc852f43df493191e26dfec2f03551f2
|
7
|
+
data.tar.gz: b0a634418e93055e3f3c2c5256176515aa990950f4927e2b0ee82055a87543f0695cf13ae4a1f5bd99ab1cec9f8e264153b8aa2ec3f4392c88c5890c17ce7c13
|
@@ -5,6 +5,7 @@ on:
|
|
5
5
|
branches: [master]
|
6
6
|
pull_request:
|
7
7
|
branches: [master]
|
8
|
+
workflow_dispatch:
|
8
9
|
|
9
10
|
jobs:
|
10
11
|
continuous_integration_build:
|
@@ -28,6 +29,9 @@ jobs:
|
|
28
29
|
|
29
30
|
runs-on: ${{ matrix.operating-system }}
|
30
31
|
|
32
|
+
env:
|
33
|
+
JAVA_OPTS: -Djdk.io.File.enableADS=true
|
34
|
+
|
31
35
|
steps:
|
32
36
|
- name: Checkout Code
|
33
37
|
uses: actions/checkout@v2
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,20 @@
|
|
5
5
|
|
6
6
|
# Change Log
|
7
7
|
|
8
|
+
## v1.13.0 (2022-12-10)
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/ruby-git/ruby-git/compare/v1.12.0...v1.13.0)
|
11
|
+
|
12
|
+
* 8349224 Update list of maintainers (#598)
|
13
|
+
* 4fe8738 In ls-files do not unescape file paths with eval (#602)
|
14
|
+
* 74b8e11 Add start_point option for checkout command (#597)
|
15
|
+
* ff6dcf4 Do not assume the default branch is 'master' in tests
|
16
|
+
* 8279298 Fix exception when Git is autoloaded (#594)
|
17
|
+
|
18
|
+
## v1.12.0
|
19
|
+
|
20
|
+
See https://github.com/ruby-git/ruby-git/releases/tag/v1.12.0
|
21
|
+
|
8
22
|
## v1.11.0
|
9
23
|
|
10
24
|
* 292087e Supress unneeded test output (#570)
|
@@ -147,4 +161,3 @@ See https://github.com/ruby-git/ruby-git/releases/tag/v1.4.0
|
|
147
161
|
## 1.0.1
|
148
162
|
|
149
163
|
* Initial version
|
150
|
-
|
data/Gemfile
CHANGED
data/MAINTAINERS.md
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
|
8
8
|
When making changes in this repository, one of the maintainers below must review and approve your pull request.
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
* [James Couball](https://github.com/jcouball)
|
11
|
+
* [Frank Throckmorton](https://github.com/frankthrock)
|
12
12
|
* [Per Lundberg](https://github.com/perlun)
|
13
|
-
* [James Couball](https://github.com/jcouball)
|
data/README.md
CHANGED
@@ -108,7 +108,7 @@ g.index.writable?
|
|
108
108
|
g.repo
|
109
109
|
g.dir
|
110
110
|
|
111
|
-
g.log # returns
|
111
|
+
g.log # returns a Git::Log object, which is an Enumerator of Git::Commit objects
|
112
112
|
g.log.since('2 weeks ago')
|
113
113
|
g.log.between('v2.5', 'v2.6')
|
114
114
|
g.log.each {|l| puts l.sha }
|
@@ -204,13 +204,23 @@ g = Git.init
|
|
204
204
|
{ :repository => '/opt/git/proj.git',
|
205
205
|
:index => '/tmp/index'} )
|
206
206
|
|
207
|
-
|
207
|
+
# Clone from a git url
|
208
|
+
git_url = 'https://github.com/ruby-git/ruby-git.git'
|
209
|
+
# Clone into the ruby-git directory
|
210
|
+
g = Git.clone(git_url)
|
211
|
+
|
212
|
+
# Clone into /tmp/clone/ruby-git-clean
|
213
|
+
name = 'ruby-git-clean'
|
214
|
+
path = '/tmp/clone'
|
215
|
+
g = Git.clone(git_url, name, :path => path)
|
216
|
+
g.dir #=> /tmp/clone/ruby-git-clean
|
217
|
+
|
208
218
|
g.config('user.name', 'Scott Chacon')
|
209
219
|
g.config('user.email', 'email@email.com')
|
210
220
|
|
211
221
|
# Clone can take an optional logger
|
212
222
|
logger = Logger.new
|
213
|
-
g = Git.clone(
|
223
|
+
g = Git.clone(git_url, NAME, :log => logger)
|
214
224
|
|
215
225
|
g.add # git add -- "."
|
216
226
|
g.add(:all=>true) # git add --all -- "."
|
@@ -234,6 +244,9 @@ g.commit('message', gpg_sign: true)
|
|
234
244
|
key_id = '0A46826A'
|
235
245
|
g.commit('message', gpg_sign: key_id)
|
236
246
|
|
247
|
+
# Skip signing a commit (overriding any global gpgsign setting)
|
248
|
+
g.commit('message', no_gpg_sign: true)
|
249
|
+
|
237
250
|
g = Git.clone(repo, 'myrepo')
|
238
251
|
g.chdir do
|
239
252
|
new_file('test-file', 'blahblahblah')
|
@@ -252,6 +265,7 @@ g.branch('existing_branch').checkout
|
|
252
265
|
g.branch('master').contains?('existing_branch')
|
253
266
|
|
254
267
|
g.checkout('new_branch')
|
268
|
+
g.checkout('new_branch', new_branch: true, start_point: 'master')
|
255
269
|
g.checkout(g.branch('new_branch'))
|
256
270
|
|
257
271
|
g.branch(name).merge(branch2)
|
@@ -278,6 +292,7 @@ g.remote(name).merge(branch)
|
|
278
292
|
g.fetch
|
279
293
|
g.fetch(g.remotes.first)
|
280
294
|
g.fetch('origin', {:ref => 'some/ref/head'} )
|
295
|
+
g.fetch(all: true, force: true, depth: 2)
|
281
296
|
|
282
297
|
g.pull
|
283
298
|
g.pull(Git::Repo, Git::Branch) # fetch and a merge
|
data/git.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
27
27
|
s.requirements = ['git 1.6.0.0, or greater']
|
28
28
|
|
29
|
+
s.add_runtime_dependency 'addressable', '~> 2.8'
|
29
30
|
s.add_runtime_dependency 'rchardet', '~> 1.8'
|
30
31
|
|
31
32
|
s.add_development_dependency 'bump', '~> 0.10'
|
@@ -35,7 +36,7 @@ Gem::Specification.new do |s|
|
|
35
36
|
|
36
37
|
unless RUBY_PLATFORM == 'java'
|
37
38
|
s.add_development_dependency 'redcarpet', '~> 3.5'
|
38
|
-
s.add_development_dependency 'yard', '~> 0.9'
|
39
|
+
s.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
|
39
40
|
s.add_development_dependency 'yardstick', '~> 0.9'
|
40
41
|
end
|
41
42
|
|
data/lib/git/base.rb
CHANGED
@@ -17,10 +17,10 @@ module Git
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# (see Git.clone)
|
20
|
-
def self.clone(
|
21
|
-
new_options = Git::Lib.new(nil, options[:log]).clone(
|
20
|
+
def self.clone(repository_url, directory, options = {})
|
21
|
+
new_options = Git::Lib.new(nil, options[:log]).clone(repository_url, directory, options)
|
22
22
|
normalize_paths(new_options, bare: options[:bare] || options[:mirror])
|
23
|
-
|
23
|
+
new(new_options)
|
24
24
|
end
|
25
25
|
|
26
26
|
# Returns (and initialize if needed) a Git::Config instance
|
@@ -336,7 +336,11 @@ module Git
|
|
336
336
|
|
337
337
|
# fetches changes from a remote branch - this does not modify the working directory,
|
338
338
|
# it just gets the changes from the remote if there are any
|
339
|
-
def fetch(remote = 'origin', opts={})
|
339
|
+
def fetch(remote = 'origin', opts = {})
|
340
|
+
if remote.is_a?(Hash)
|
341
|
+
opts = remote
|
342
|
+
remote = nil
|
343
|
+
end
|
340
344
|
self.lib.fetch(remote, opts)
|
341
345
|
end
|
342
346
|
|
data/lib/git/lib.rb
CHANGED
@@ -63,6 +63,8 @@ module Git
|
|
63
63
|
@git_work_dir = base[:working_directory]
|
64
64
|
end
|
65
65
|
@logger = logger
|
66
|
+
|
67
|
+
Git::Lib.warn_if_old_command(self)
|
66
68
|
end
|
67
69
|
|
68
70
|
# creates or reinitializes the repository
|
@@ -95,9 +97,9 @@ module Git
|
|
95
97
|
#
|
96
98
|
# @return [Hash] the options to pass to {Git::Base.new}
|
97
99
|
#
|
98
|
-
def clone(
|
100
|
+
def clone(repository_url, directory, opts = {})
|
99
101
|
@path = opts[:path] || '.'
|
100
|
-
clone_dir = opts[:path] ? File.join(@path,
|
102
|
+
clone_dir = opts[:path] ? File.join(@path, directory) : directory
|
101
103
|
|
102
104
|
arr_opts = []
|
103
105
|
arr_opts << '--bare' if opts[:bare]
|
@@ -106,11 +108,11 @@ module Git
|
|
106
108
|
arr_opts << '--config' << opts[:config] if opts[:config]
|
107
109
|
arr_opts << '--origin' << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin]
|
108
110
|
arr_opts << '--recursive' if opts[:recursive]
|
109
|
-
arr_opts <<
|
111
|
+
arr_opts << '--mirror' if opts[:mirror]
|
110
112
|
|
111
113
|
arr_opts << '--'
|
112
114
|
|
113
|
-
arr_opts <<
|
115
|
+
arr_opts << repository_url
|
114
116
|
arr_opts << clone_dir
|
115
117
|
|
116
118
|
command('clone', arr_opts)
|
@@ -486,7 +488,9 @@ module Git
|
|
486
488
|
command_lines('ls-files', '--stage', location).each do |line|
|
487
489
|
(info, file) = line.split("\t")
|
488
490
|
(mode, sha, stage) = info.split
|
489
|
-
file
|
491
|
+
if file.start_with?('"') && file.end_with?('"')
|
492
|
+
file = Git::EscapedPath.new(file[1..-2]).unescape
|
493
|
+
end
|
490
494
|
hsh[file] = {:path => file, :mode_index => mode, :sha_index => sha, :stage => stage}
|
491
495
|
end
|
492
496
|
hsh
|
@@ -647,7 +651,8 @@ module Git
|
|
647
651
|
# :date
|
648
652
|
# :no_verify
|
649
653
|
# :allow_empty_message
|
650
|
-
# :gpg_sign
|
654
|
+
# :gpg_sign (accepts true or a gpg key ID as a String)
|
655
|
+
# :no_gpg_sign (conflicts with :gpg_sign)
|
651
656
|
#
|
652
657
|
# @param [String] message the commit message to be used
|
653
658
|
# @param [Hash] opts the commit options to be used
|
@@ -661,13 +666,18 @@ module Git
|
|
661
666
|
arr_opts << "--date=#{opts[:date]}" if opts[:date].is_a? String
|
662
667
|
arr_opts << '--no-verify' if opts[:no_verify]
|
663
668
|
arr_opts << '--allow-empty-message' if opts[:allow_empty_message]
|
664
|
-
|
669
|
+
|
670
|
+
if opts[:gpg_sign] && opts[:no_gpg_sign]
|
671
|
+
raise ArgumentError, 'cannot specify :gpg_sign and :no_gpg_sign'
|
672
|
+
elsif opts[:gpg_sign]
|
665
673
|
arr_opts <<
|
666
674
|
if opts[:gpg_sign] == true
|
667
675
|
'--gpg-sign'
|
668
676
|
else
|
669
677
|
"--gpg-sign=#{opts[:gpg_sign]}"
|
670
678
|
end
|
679
|
+
elsif opts[:no_gpg_sign]
|
680
|
+
arr_opts << '--no-gpg-sign'
|
671
681
|
end
|
672
682
|
|
673
683
|
command('commit', arr_opts)
|
@@ -756,11 +766,21 @@ module Git
|
|
756
766
|
command('branch', '-D', branch)
|
757
767
|
end
|
758
768
|
|
769
|
+
# Runs checkout command to checkout or create branch
|
770
|
+
#
|
771
|
+
# accepts options:
|
772
|
+
# :new_branch
|
773
|
+
# :force
|
774
|
+
# :start_point
|
775
|
+
#
|
776
|
+
# @param [String] branch
|
777
|
+
# @param [Hash] opts
|
759
778
|
def checkout(branch, opts = {})
|
760
779
|
arr_opts = []
|
761
780
|
arr_opts << '-b' if opts[:new_branch] || opts[:b]
|
762
781
|
arr_opts << '--force' if opts[:force] || opts[:f]
|
763
782
|
arr_opts << branch
|
783
|
+
arr_opts << opts[:start_point] if opts[:start_point] && arr_opts.include?('-b')
|
764
784
|
|
765
785
|
command('checkout', arr_opts)
|
766
786
|
end
|
@@ -877,14 +897,15 @@ module Git
|
|
877
897
|
|
878
898
|
def fetch(remote, opts)
|
879
899
|
arr_opts = []
|
900
|
+
arr_opts << '--all' if opts[:all]
|
880
901
|
arr_opts << '--tags' if opts[:t] || opts[:tags]
|
881
902
|
arr_opts << '--prune' if opts[:p] || opts[:prune]
|
882
903
|
arr_opts << '--prune-tags' if opts[:P] || opts[:'prune-tags']
|
883
904
|
arr_opts << '--force' if opts[:f] || opts[:force]
|
884
905
|
arr_opts << '--unshallow' if opts[:unshallow]
|
885
906
|
arr_opts << '--depth' << opts[:depth] if opts[:depth]
|
886
|
-
arr_opts << '--'
|
887
|
-
arr_opts << remote
|
907
|
+
arr_opts << '--' if remote || opts[:ref]
|
908
|
+
arr_opts << remote if remote
|
888
909
|
arr_opts << opts[:ref] if opts[:ref]
|
889
910
|
|
890
911
|
command('fetch', arr_opts)
|
@@ -1020,6 +1041,13 @@ module Git
|
|
1020
1041
|
(self.current_command_version <=> self.required_command_version) >= 0
|
1021
1042
|
end
|
1022
1043
|
|
1044
|
+
def self.warn_if_old_command(lib)
|
1045
|
+
return true if @version_checked
|
1046
|
+
unless lib.meets_required_version?
|
1047
|
+
$stderr.puts "[WARNING] The git gem requires git #{lib.required_command_version.join('.')} or later, but only found #{lib.current_command_version.join('.')}. You should probably upgrade."
|
1048
|
+
end
|
1049
|
+
@version_checked = true
|
1050
|
+
end
|
1023
1051
|
|
1024
1052
|
private
|
1025
1053
|
|
data/lib/git/url.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable/uri'
|
4
|
+
|
5
|
+
module Git
|
6
|
+
# Methods for parsing a Git URL
|
7
|
+
#
|
8
|
+
# Any URL that can be passed to `git clone` can be parsed by this class.
|
9
|
+
#
|
10
|
+
# @see https://git-scm.com/docs/git-clone#_git_urls GIT URLs
|
11
|
+
# @see https://github.com/sporkmonger/addressable Addresable::URI
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
#
|
15
|
+
class URL
|
16
|
+
# Regexp used to match a Git URL with an alternative SSH syntax
|
17
|
+
# such as `user@host:path`
|
18
|
+
#
|
19
|
+
GIT_ALTERNATIVE_SSH_SYNTAX = %r{
|
20
|
+
^
|
21
|
+
(?:(?<user>[^@/]+)@)? # user or nil
|
22
|
+
(?<host>[^:/]+) # host is required
|
23
|
+
:(?!/) # : serparator is required, but must not be followed by /
|
24
|
+
(?<path>.*?) # path is required
|
25
|
+
$
|
26
|
+
}x.freeze
|
27
|
+
|
28
|
+
# Parse a Git URL and return an Addressable::URI object
|
29
|
+
#
|
30
|
+
# The URI returned can be converted back to a string with 'to_s'. This is
|
31
|
+
# guaranteed to return the same URL string that was parsed.
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# uri = Git::URL.parse('https://github.com/ruby-git/ruby-git.git')
|
35
|
+
# #=> #<Addressable::URI:0x44c URI:https://github.com/ruby-git/ruby-git.git>
|
36
|
+
# uri.scheme #=> "https"
|
37
|
+
# uri.host #=> "github.com"
|
38
|
+
# uri.path #=> "/ruby-git/ruby-git.git"
|
39
|
+
#
|
40
|
+
# Git::URL.parse('/Users/James/projects/ruby-git')
|
41
|
+
# #=> #<Addressable::URI:0x438 URI:/Users/James/projects/ruby-git>
|
42
|
+
#
|
43
|
+
# @param url [String] the Git URL to parse
|
44
|
+
#
|
45
|
+
# @return [Addressable::URI] the parsed URI
|
46
|
+
#
|
47
|
+
def self.parse(url)
|
48
|
+
if !url.start_with?('file:') && (m = GIT_ALTERNATIVE_SSH_SYNTAX.match(url))
|
49
|
+
GitAltURI.new(user: m[:user], host: m[:host], path: m[:path])
|
50
|
+
else
|
51
|
+
Addressable::URI.parse(url)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# The directory `git clone` would use for the repository directory for the given URL
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# Git::URL.clone_to('https://github.com/ruby-git/ruby-git.git') #=> 'ruby-git'
|
59
|
+
#
|
60
|
+
# @param url [String] the Git URL containing the repository directory
|
61
|
+
#
|
62
|
+
# @return [String] the name of the repository directory
|
63
|
+
#
|
64
|
+
def self.clone_to(url, bare: false, mirror: false)
|
65
|
+
uri = parse(url)
|
66
|
+
path_parts = uri.path.split('/')
|
67
|
+
path_parts.pop if path_parts.last == '.git'
|
68
|
+
directory = path_parts.last
|
69
|
+
if bare || mirror
|
70
|
+
directory += '.git' unless directory.end_with?('.git')
|
71
|
+
elsif directory.end_with?('.git')
|
72
|
+
directory = directory[0..-5]
|
73
|
+
end
|
74
|
+
directory
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# The URI for git's alternative scp-like syntax
|
79
|
+
#
|
80
|
+
# This class is necessary to ensure that #to_s returns the same string
|
81
|
+
# that was passed to the initializer.
|
82
|
+
#
|
83
|
+
# @api public
|
84
|
+
#
|
85
|
+
class GitAltURI < Addressable::URI
|
86
|
+
# Create a new GitAltURI object
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# uri = Git::GitAltURI.new(user: 'james', host: 'github.com', path: 'james/ruby-git')
|
90
|
+
# uri.to_s #=> 'james@github.com/james/ruby-git'
|
91
|
+
#
|
92
|
+
# @param user [String, nil] the user from the URL or nil
|
93
|
+
# @param host [String] the host from the URL
|
94
|
+
# @param path [String] the path from the URL
|
95
|
+
#
|
96
|
+
def initialize(user:, host:, path:)
|
97
|
+
super(scheme: 'git-alt', user: user, host: host, path: path)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Convert the URI to a String
|
101
|
+
#
|
102
|
+
# Addressible::URI forces path to be absolute by prepending a '/' to the
|
103
|
+
# path. This method removes the '/' when converting back to a string
|
104
|
+
# since that is what is expected by git. The following is a valid git URL:
|
105
|
+
#
|
106
|
+
# `james@github.com:ruby-git/ruby-git.git`
|
107
|
+
#
|
108
|
+
# and the following (with the initial '/'' in the path) is NOT a valid git URL:
|
109
|
+
#
|
110
|
+
# `james@github.com:/ruby-git/ruby-git.git`
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# uri = Git::GitAltURI.new(user: 'james', host: 'github.com', path: 'james/ruby-git')
|
114
|
+
# uri.path #=> '/james/ruby-git'
|
115
|
+
# uri.to_s #=> 'james@github.com:james/ruby-git'
|
116
|
+
#
|
117
|
+
# @return [String] the URI as a String
|
118
|
+
#
|
119
|
+
def to_s
|
120
|
+
if user
|
121
|
+
"#{user}@#{host}:#{path[1..-1]}"
|
122
|
+
else
|
123
|
+
"#{host}:#{path[1..-1]}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/git/version.rb
CHANGED
data/lib/git.rb
CHANGED
@@ -21,16 +21,12 @@ require 'git/repository'
|
|
21
21
|
require 'git/status'
|
22
22
|
require 'git/stash'
|
23
23
|
require 'git/stashes'
|
24
|
+
require 'git/url'
|
24
25
|
require 'git/version'
|
25
26
|
require 'git/working_directory'
|
26
27
|
require 'git/worktree'
|
27
28
|
require 'git/worktrees'
|
28
29
|
|
29
|
-
lib = Git::Lib.new(nil, nil)
|
30
|
-
unless lib.meets_required_version?
|
31
|
-
$stderr.puts "[WARNING] The git gem requires git #{lib.required_command_version.join('.')} or later, but only found #{lib.current_command_version.join('.')}. You should probably upgrade."
|
32
|
-
end
|
33
|
-
|
34
30
|
# The Git module provides the basic functions to open a git
|
35
31
|
# reference to work with. You can open a working directory,
|
36
32
|
# open a bare repository, initialize a new repo or clone an
|
@@ -106,11 +102,23 @@ module Git
|
|
106
102
|
# @see https://git-scm.com/docs/git-clone git clone
|
107
103
|
# @see https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a GIT URLs
|
108
104
|
#
|
109
|
-
# @param [URI, Pathname]
|
105
|
+
# @param repository_url [URI, Pathname] The (possibly remote) repository url to clone
|
110
106
|
# from. See [GIT URLS](https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a)
|
111
107
|
# for more information.
|
112
108
|
#
|
113
|
-
# @param [Pathname]
|
109
|
+
# @param directory [Pathname, nil] The directory to clone into
|
110
|
+
#
|
111
|
+
# If `directory` is a relative directory it is relative to the `path` option if
|
112
|
+
# given. If `path` is not given, `directory` is relative to the current working
|
113
|
+
# directory.
|
114
|
+
#
|
115
|
+
# If `nil`, `directory` will be set to the basename of the last component of
|
116
|
+
# the path from the `repository_url`. For example, for the URL:
|
117
|
+
# `https://github.com/org/repo.git`, `directory` will be set to `repo`.
|
118
|
+
#
|
119
|
+
# If the last component of the path is `.git`, the next-to-last component of
|
120
|
+
# the path is used. For example, for the URL `/Users/me/foo/.git`, `directory`
|
121
|
+
# will be set to `foo`.
|
114
122
|
#
|
115
123
|
# @param [Hash] options The options for this command (see list of valid
|
116
124
|
# options below)
|
@@ -157,8 +165,10 @@ module Git
|
|
157
165
|
# @return [Git::Base] an object that can execute git commands in the context
|
158
166
|
# of the cloned local working copy or cloned repository.
|
159
167
|
#
|
160
|
-
def self.clone(
|
161
|
-
|
168
|
+
def self.clone(repository_url, directory = nil, options = {})
|
169
|
+
clone_to_options = options.select { |key, _value| %i[bare mirror].include?(key) }
|
170
|
+
directory ||= Git::URL.clone_to(repository_url, **clone_to_options)
|
171
|
+
Base.clone(repository_url, directory, options)
|
162
172
|
end
|
163
173
|
|
164
174
|
# Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon and others
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: addressable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.8'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rchardet
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +115,9 @@ dependencies:
|
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0.9'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.9.28
|
104
121
|
type: :development
|
105
122
|
prerelease: false
|
106
123
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -108,6 +125,9 @@ dependencies:
|
|
108
125
|
- - "~>"
|
109
126
|
- !ruby/object:Gem::Version
|
110
127
|
version: '0.9'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.9.28
|
111
131
|
- !ruby/object:Gem::Dependency
|
112
132
|
name: yardstick
|
113
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +189,7 @@ files:
|
|
169
189
|
- lib/git/stash.rb
|
170
190
|
- lib/git/stashes.rb
|
171
191
|
- lib/git/status.rb
|
192
|
+
- lib/git/url.rb
|
172
193
|
- lib/git/version.rb
|
173
194
|
- lib/git/working_directory.rb
|
174
195
|
- lib/git/worktree.rb
|
@@ -196,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
217
|
version: '0'
|
197
218
|
requirements:
|
198
219
|
- git 1.6.0.0, or greater
|
199
|
-
rubygems_version: 3.
|
220
|
+
rubygems_version: 3.3.26
|
200
221
|
signing_key:
|
201
222
|
specification_version: 4
|
202
223
|
summary: An API to create, read, and manipulate Git repositories
|