git 1.10.1 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dd58567bba3a5effab0e3d3f565f5b3891dcf056ef4df11c1521037bbe9f489
4
- data.tar.gz: a1f8f9968a3927ce99f393805c34b0ca23941c37f27607d296eaecba9dc0f872
3
+ metadata.gz: '03386fbc4d48647754608adba467800440ec80e5e8aecddac930a3e2565827bd'
4
+ data.tar.gz: 180866b01d05c40d495638ee8ddf2a1d8ca2e534250575c09c20728a2473855e
5
5
  SHA512:
6
- metadata.gz: b1231323bde0b63677f46945800dc950a004cd854bee8c1d5a6711c8709c3dd87fb0c187f54c39c94ae07f92674f27a94b23fe3200a1799992f272c0bd84d315
7
- data.tar.gz: 8d89a33a9cbee9357f9a4ffb568ec38506749aa81b931f9b2e862af0420c549c1738fde90e48eede6650c3202d31b9463e852eea5b358020b5561e5a60e12ef3
6
+ metadata.gz: b5115fff1ce7fbbc3a0fb8d22b8f27b6c3acb00e27613e3e8d0a4d760c2b40a0355a3c2e57e3e8d14e91545f985eea51caca44eab4b04b112f00393e64f48216
7
+ data.tar.gz: 4494ee6206a07e17b2c1bb983c7519689364c1ec15bfa811a3ab4cf380aba9a29c783adfff82917c0379a7911b2a5a51d0661bf928f69d9502a271d8d11a846e
@@ -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,25 @@
5
5
 
6
6
  # Change Log
7
7
 
8
+ ## v1.12.0
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.12.0
11
+
12
+ ## v1.11.0
13
+
14
+ * 292087e Supress unneeded test output (#570)
15
+ * 19dfe5e Add support for fetch options "--force/-f" and "--prune-tags/-P". (#563)
16
+ * 018d919 Fix bug when grepping lines that contain numbers surrounded by colons (#566)
17
+ * c04d16e remove from maintainer (#567)
18
+ * 291ca09 Address command line injection in Git::Lib#fetch
19
+ * 521b8e7 Release v1.10.2 (#561)
20
+
21
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.11.0
22
+
23
+ ## v1.10.2
24
+
25
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.2
26
+
8
27
  ## 1.10.1
9
28
 
10
29
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.10.1
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- gemspec :name => 'git'
3
+ source 'https://rubygems.org'
4
4
 
5
+ gemspec name: 'git'
data/MAINTAINERS.md CHANGED
@@ -10,5 +10,4 @@ When making changes in this repository, one of the maintainers below must review
10
10
  ### Maintainers
11
11
 
12
12
  * [Per Lundberg](https://github.com/perlun)
13
- * [Vern Burton](https://github.com/tarcinil)
14
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 array of Git::Commit objects
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
- g = Git.clone(URI, NAME, :path => '/tmp/checkout')
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(URI, NAME, :log => logger)
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')
@@ -278,6 +291,7 @@ g.remote(name).merge(branch)
278
291
  g.fetch
279
292
  g.fetch(g.remotes.first)
280
293
  g.fetch('origin', {:ref => 'some/ref/head'} )
294
+ g.fetch(all: true, force: true, depth: 2)
281
295
 
282
296
  g.pull
283
297
  g.pull(Git::Repo, Git::Branch) # fetch and a merge
data/git.gemspec CHANGED
@@ -26,21 +26,23 @@ 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
 
32
+ s.add_development_dependency 'bump', '~> 0.10'
31
33
  s.add_development_dependency 'minitar', '~> 0.9'
32
34
  s.add_development_dependency 'rake', '~> 13.0'
33
35
  s.add_development_dependency 'test-unit', '~> 3.3'
34
36
 
35
37
  unless RUBY_PLATFORM == 'java'
36
38
  s.add_development_dependency 'redcarpet', '~> 3.5'
37
- s.add_development_dependency 'yard', '~> 0.9'
39
+ s.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
38
40
  s.add_development_dependency 'yardstick', '~> 0.9'
39
41
  end
40
42
 
41
43
  # Specify which files should be added to the gem when it is released.
42
44
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
43
45
  s.files = Dir.chdir(File.expand_path(__dir__)) do
44
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features)/}) }
46
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tests|spec|features|bin)/}) }
45
47
  end
46
48
  end
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(repository, name, options = {})
21
- new_options = Git::Lib.new(nil, options[:log]).clone(repository, name, options)
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
- self.new(new_options)
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
@@ -95,9 +95,9 @@ module Git
95
95
  #
96
96
  # @return [Hash] the options to pass to {Git::Base.new}
97
97
  #
98
- def clone(repository, name, opts = {})
98
+ def clone(repository_url, directory, opts = {})
99
99
  @path = opts[:path] || '.'
100
- clone_dir = opts[:path] ? File.join(@path, name) : name
100
+ clone_dir = opts[:path] ? File.join(@path, directory) : directory
101
101
 
102
102
  arr_opts = []
103
103
  arr_opts << '--bare' if opts[:bare]
@@ -106,11 +106,11 @@ module Git
106
106
  arr_opts << '--config' << opts[:config] if opts[:config]
107
107
  arr_opts << '--origin' << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin]
108
108
  arr_opts << '--recursive' if opts[:recursive]
109
- arr_opts << "--mirror" if opts[:mirror]
109
+ arr_opts << '--mirror' if opts[:mirror]
110
110
 
111
111
  arr_opts << '--'
112
112
 
113
- arr_opts << repository
113
+ arr_opts << repository_url
114
114
  arr_opts << clone_dir
115
115
 
116
116
  command('clone', arr_opts)
@@ -419,7 +419,7 @@ module Git
419
419
 
420
420
  hsh = {}
421
421
  command_lines('grep', grep_opts).each do |line|
422
- if m = /(.*)\:(\d+)\:(.*)/.match(line)
422
+ if m = /(.*?)\:(\d+)\:(.*)/.match(line)
423
423
  hsh[m[1]] ||= []
424
424
  hsh[m[1]] << [m[2].to_i, m[3]]
425
425
  end
@@ -647,7 +647,8 @@ module Git
647
647
  # :date
648
648
  # :no_verify
649
649
  # :allow_empty_message
650
- # :gpg_sign
650
+ # :gpg_sign (accepts true or a gpg key ID as a String)
651
+ # :no_gpg_sign (conflicts with :gpg_sign)
651
652
  #
652
653
  # @param [String] message the commit message to be used
653
654
  # @param [Hash] opts the commit options to be used
@@ -661,13 +662,18 @@ module Git
661
662
  arr_opts << "--date=#{opts[:date]}" if opts[:date].is_a? String
662
663
  arr_opts << '--no-verify' if opts[:no_verify]
663
664
  arr_opts << '--allow-empty-message' if opts[:allow_empty_message]
664
- if opts[:gpg_sign]
665
+
666
+ if opts[:gpg_sign] && opts[:no_gpg_sign]
667
+ raise ArgumentError, 'cannot specify :gpg_sign and :no_gpg_sign'
668
+ elsif opts[:gpg_sign]
665
669
  arr_opts <<
666
670
  if opts[:gpg_sign] == true
667
671
  '--gpg-sign'
668
672
  else
669
673
  "--gpg-sign=#{opts[:gpg_sign]}"
670
674
  end
675
+ elsif opts[:no_gpg_sign]
676
+ arr_opts << '--no-gpg-sign'
671
677
  end
672
678
 
673
679
  command('commit', arr_opts)
@@ -875,14 +881,18 @@ module Git
875
881
  command('tag', arr_opts)
876
882
  end
877
883
 
878
-
879
884
  def fetch(remote, opts)
880
- arr_opts = [remote]
881
- arr_opts << opts[:ref] if opts[:ref]
885
+ arr_opts = []
886
+ arr_opts << '--all' if opts[:all]
882
887
  arr_opts << '--tags' if opts[:t] || opts[:tags]
883
888
  arr_opts << '--prune' if opts[:p] || opts[:prune]
889
+ arr_opts << '--prune-tags' if opts[:P] || opts[:'prune-tags']
890
+ arr_opts << '--force' if opts[:f] || opts[:force]
884
891
  arr_opts << '--unshallow' if opts[:unshallow]
885
892
  arr_opts << '--depth' << opts[:depth] if opts[:depth]
893
+ arr_opts << '--' if remote || opts[:ref]
894
+ arr_opts << remote if remote
895
+ arr_opts << opts[:ref] if opts[:ref]
886
896
 
887
897
  command('fetch', arr_opts)
888
898
  end
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
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  # The current gem version
3
3
  # @return [String] the current gem version.
4
- VERSION='1.10.1'
4
+ VERSION='1.12.0'
5
5
  end
data/lib/git.rb CHANGED
@@ -21,6 +21,7 @@ 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'
@@ -106,11 +107,23 @@ module Git
106
107
  # @see https://git-scm.com/docs/git-clone git clone
107
108
  # @see https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a GIT URLs
108
109
  #
109
- # @param [URI, Pathname] repository The (possibly remote) repository to clone
110
+ # @param repository_url [URI, Pathname] The (possibly remote) repository url to clone
110
111
  # from. See [GIT URLS](https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a)
111
112
  # for more information.
112
113
  #
113
- # @param [Pathname] name The directory to clone into.
114
+ # @param directory [Pathname, nil] The directory to clone into
115
+ #
116
+ # If `directory` is a relative directory it is relative to the `path` option if
117
+ # given. If `path` is not given, `directory` is relative to the current working
118
+ # directory.
119
+ #
120
+ # If `nil`, `directory` will be set to the basename of the last component of
121
+ # the path from the `repository_url`. For example, for the URL:
122
+ # `https://github.com/org/repo.git`, `directory` will be set to `repo`.
123
+ #
124
+ # If the last component of the path is `.git`, the next-to-last component of
125
+ # the path is used. For example, for the URL `/Users/me/foo/.git`, `directory`
126
+ # will be set to `foo`.
114
127
  #
115
128
  # @param [Hash] options The options for this command (see list of valid
116
129
  # options below)
@@ -157,8 +170,10 @@ module Git
157
170
  # @return [Git::Base] an object that can execute git commands in the context
158
171
  # of the cloned local working copy or cloned repository.
159
172
  #
160
- def self.clone(repository, name, options = {})
161
- Base.clone(repository, name, options)
173
+ def self.clone(repository_url, directory = nil, options = {})
174
+ clone_to_options = options.select { |key, _value| %i[bare mirror].include?(key) }
175
+ directory ||= Git::URL.clone_to(repository_url, **clone_to_options)
176
+ Base.clone(repository_url, directory, options)
162
177
  end
163
178
 
164
179
  # 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.10.1
4
+ version: 1.12.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-01-03 00:00:00.000000000 Z
11
+ date: 2022-08-18 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
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bump
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.10'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: minitar
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +115,9 @@ dependencies:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
117
  version: '0.9'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.9.28
90
121
  type: :development
91
122
  prerelease: false
92
123
  version_requirements: !ruby/object:Gem::Requirement
@@ -94,6 +125,9 @@ dependencies:
94
125
  - - "~>"
95
126
  - !ruby/object:Gem::Version
96
127
  version: '0.9'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 0.9.28
97
131
  - !ruby/object:Gem::Dependency
98
132
  name: yardstick
99
133
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +189,7 @@ files:
155
189
  - lib/git/stash.rb
156
190
  - lib/git/stashes.rb
157
191
  - lib/git/status.rb
192
+ - lib/git/url.rb
158
193
  - lib/git/version.rb
159
194
  - lib/git/working_directory.rb
160
195
  - lib/git/worktree.rb