rjgit 5.7.0.0 → 5.9.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c44778442b606fcefdcc05154037588f9cdbda66d37bf9885318815b4eb3799
4
- data.tar.gz: eab78cd321c6c45249c0768540f3d4ddcd06d6f04bc1dc6c097b86577341c481
3
+ metadata.gz: 7f03c8f0d9e77ec4568625a3ec9cbfb87a5b6ec4ae7a1c1f540a5cde0599d9be
4
+ data.tar.gz: 81f752231d8d1714639f0422b9fb08fe3179837ab171f4ddb919d32159fab52b
5
5
  SHA512:
6
- metadata.gz: facb928fe049b87c9a50f9ae6151a4e0545990373bad18f66a95bf523ce9666b288f29338a98694a0e5f627b6a55ffe58c61dc6fa2b4b7293f293d96c729bf36
7
- data.tar.gz: 1fbf4acc0fce8f4a849a91f84d7a9bec7a19b1c8f11b306aea98b7c73970b8eabdcd03734b015dbacd057e747f0a6ca20f1c0a78499102801e791a134c9c56ce
6
+ metadata.gz: '05482710f19d6205ca490ef7a3c49244ae584c1116a8de447d4eb34d7624d4b92e34fdd7d932752c823a62459b41b94afcb0052702a9e1389615831dd19d8388'
7
+ data.tar.gz: 74bff6ee3bc9361e1638697203d6cf64048408f2dcb9d2bc108ff0d7a69918a8fdbe3c27e5ed8a81e869267a413f32dc218e8a1b80ee517e0631ff90fcd1c060
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'mime-types', '~> 2.6.2'
3
+ gem 'mime-types', '~> 3.3.1'
4
4
  gem 'rake', '>= 12.3.3'
5
5
 
6
6
  gem 'coveralls', '~> 0.8.23', require: false
data/README.md CHANGED
@@ -6,6 +6,7 @@ RJGit
6
6
  [![Build Status](https://travis-ci.org/repotag/rjgit.png)](https://travis-ci.org/repotag/rjgit)
7
7
  [![Coverage Status](https://coveralls.io/repos/repotag/rjgit/badge.png?branch=master)](https://coveralls.io/r/repotag/rjgit)
8
8
  [![Gem Version](https://badge.fury.io/rb/rjgit.png)](http://badge.fury.io/rb/rjgit)
9
+ [![Cutting Edge Dependency Status](https://dometto-cuttingedge.herokuapp.com/github/repotag/rjgit/svg 'Cutting Edge Dependency Status')](https://dometto-cuttingedge.herokuapp.com/github/repotag/rjgit/info)
9
10
 
10
11
  Summary
11
12
  -------
@@ -2,6 +2,7 @@ module RJGit
2
2
 
3
3
  # PersonIdent in JGit
4
4
  import 'org.eclipse.jgit.lib.PersonIdent'
5
+ import 'java.util.TimeZone'
5
6
 
6
7
  class Actor
7
8
 
@@ -17,10 +18,11 @@ module RJGit
17
18
  return self.new(name, email)
18
19
  end
19
20
 
20
- def initialize(name, email)
21
+ def initialize(name, email, time = nil)
21
22
  @name = name
22
23
  @email = email
23
- @person_ident = PersonIdent.new(name, email)
24
+ @time = time
25
+ @person_ident = @time ? PersonIdent.new(name, email, time.to_java, TimeZone.getTimeZone(time.zone)) : PersonIdent.new(name, email)
24
26
  end
25
27
 
26
28
  # Create an Actor from a string.
@@ -43,7 +45,8 @@ module RJGit
43
45
  # time - The Time the commit was authored or committed.
44
46
  #
45
47
  # Returns a String.
46
- def output(time)
48
+ def output(time = nil)
49
+ time = time || self.time
47
50
  offset = time.utc_offset / 60
48
51
  "%s <%s> %d %+.2d%.2d" % [
49
52
  @name,
@@ -52,6 +55,10 @@ module RJGit
52
55
  offset / 60,
53
56
  offset.abs % 60]
54
57
  end
58
+
59
+ def time
60
+ Time.at(@person_ident.getWhen.getTime/1000)
61
+ end
55
62
 
56
63
  end
57
64
 
@@ -36,7 +36,7 @@ module RJGit
36
36
  # The binary contents of this blob.
37
37
  # Returns String
38
38
  def data
39
- @data ||= RJGit::Porcelain.cat_file(@jrepo, @jblob)
39
+ @data ||= RJGit::Porcelain.cat_file(@jrepo, self)
40
40
  end
41
41
 
42
42
  def is_symlink?
@@ -27,12 +27,17 @@ module RJGit
27
27
 
28
28
  module Porcelain
29
29
 
30
+ import 'java.io.IOException'
30
31
  import 'org.eclipse.jgit.lib.Constants'
31
32
  import 'org.eclipse.jgit.api.AddCommand'
32
33
  import 'org.eclipse.jgit.api.CommitCommand'
33
34
  import 'org.eclipse.jgit.api.BlameCommand'
35
+ import 'org.eclipse.jgit.api.errors.RefNotFoundException'
34
36
  import 'org.eclipse.jgit.blame.BlameGenerator'
35
37
  import 'org.eclipse.jgit.blame.BlameResult'
38
+ import 'org.eclipse.jgit.errors.IncorrectObjectTypeException'
39
+ import 'org.eclipse.jgit.errors.InvalidPatternException'
40
+ import 'org.eclipse.jgit.errors.MissingObjectException'
36
41
  import 'org.eclipse.jgit.treewalk.CanonicalTreeParser'
37
42
  import 'org.eclipse.jgit.diff.DiffFormatter'
38
43
 
@@ -51,10 +56,11 @@ module RJGit
51
56
 
52
57
  # http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg00558.html
53
58
  def self.cat_file(repository, blob)
59
+ mode = blob.mode if blob.respond_to?(:mode)
54
60
  jrepo = RJGit.repository_type(repository)
55
61
  jblob = RJGit.blob_type(blob)
56
62
  # Try to resolve symlinks; return nil otherwise
57
- mode = RJGit.get_file_mode(jrepo, jblob)
63
+ mode ||= RJGit.get_file_mode(jrepo, jblob)
58
64
  if mode == SYMLINK_TYPE
59
65
  symlink_source = jrepo.open(jblob.id).get_bytes.to_a.pack('c*').force_encoding('UTF-8')
60
66
  blob = Blob.find_blob(jrepo, symlink_source)
@@ -163,6 +169,80 @@ module RJGit
163
169
  RJGit.convert_diff_entries(diff_entries)
164
170
  end
165
171
 
172
+ def self.describe(repository, ref, options = {})
173
+ options = {:always => false, :long => false, :tags => false, :match => []}.merge(options)
174
+ repo = RJGit.repository_type(repository)
175
+ git = RubyGit.new(repo).jgit
176
+ command = git.describe.
177
+ set_always(options[:always]).
178
+ set_long(options[:long]).
179
+ set_tags(options[:tags])
180
+ begin
181
+ command = command.set_target(ref)
182
+ rescue IncorrectObjectTypeException, IOException, MissingObjectException, RefNotFoundException
183
+ return nil
184
+ end
185
+ options[:match].each do |match|
186
+ begin
187
+ command = command.set_match(match)
188
+ rescue InvalidPatternException
189
+ return nil
190
+ end
191
+ end
192
+ command.call
193
+ end
194
+
195
+ # options:
196
+ # * ref
197
+ # * path_filter
198
+ # * case_insensitive
199
+ def self.grep(repository, query, options={})
200
+ case_insensitive = options[:case_insensitive]
201
+ repo = RJGit.repository_type(repository)
202
+ walk = RevWalk.new(repo)
203
+ ls_tree_options = {:recursive => true, :path_filter => options[:path_filter]}
204
+
205
+ query = case query
206
+ when Regexp then query
207
+ when String then Regexp.new(Regexp.escape(query))
208
+ else raise "A #{query.class} was passed to #{self}.grep(). Only Regexps and Strings are supported!"
209
+ end
210
+
211
+ query = Regexp.new(query.source, query.options | Regexp::IGNORECASE) if case_insensitive
212
+
213
+ # We optimize below by first grepping the entire file, and then, if a match is found, then identifying the individual line.
214
+ # To avoid missing full-line matches during the optimization, we first convert multiline anchors to single-line anchors.
215
+ query = Regexp.new(query.source.gsub(/\A\\A/, '^').gsub(/\\z\z/, '$'), query.options)
216
+
217
+ ref = options.fetch(:ref, 'HEAD')
218
+ files_to_scan = ls_tree(repo, nil, ref, ls_tree_options)
219
+
220
+ files_to_scan.each_with_object({}) do |file, result|
221
+ id = if file[:mode] == SYMLINK_TYPE
222
+ symlink_source = repo.open(ObjectId.from_string(file[:id])).get_bytes.to_a.pack('c*').force_encoding('UTF-8')
223
+ unless symlink_source[File::SEPARATOR]
224
+ dir = file[:path].split(File::SEPARATOR)
225
+ dir[-1] = symlink_source
226
+ symlink_source = File.join(dir)
227
+ end
228
+ Blob.find_blob(repo, symlink_source, ref).jblob.id
229
+ else
230
+ ObjectId.from_string(file[:id])
231
+ end
232
+ bytes = repo.open(id).get_bytes
233
+
234
+ next if RawText.is_binary(bytes)
235
+
236
+ file_contents = bytes.to_s
237
+ next unless query.match(file_contents)
238
+
239
+ rows = file_contents.split("\n")
240
+ data = rows.grep(query)
241
+ next if data.empty?
242
+
243
+ result[file[:path]] = data
244
+ end
245
+ end
166
246
  end
167
247
 
168
248
  module Plumbing
@@ -1,3 +1,3 @@
1
1
  module RJGit
2
- VERSION = "5.7.0.0"
2
+ VERSION = "5.9.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.7.0.0
4
+ version: 5.9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Engelen
@@ -12,14 +12,14 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-03-27 00:00:00.000000000 Z
15
+ date: 2020-11-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.15'
22
+ version: '3.3'
23
23
  name: mime-types
24
24
  prerelease: false
25
25
  type: :runtime
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: '1.15'
30
+ version: '3.3'
31
31
  description: JRuby wrapper around the JGit library for manipulating git repositories
32
32
  in code.
33
33
  email: repotag-dev@googlegroups.com
@@ -49,7 +49,8 @@ files:
49
49
  - lib/java/jars/bcpkix-jdk15on-161.jar
50
50
  - lib/java/jars/bcprov-jdk15on-161.jar
51
51
  - lib/java/jars/jsch-0.1.54.jar
52
- - lib/java/jars/org.eclipse.jgit-5.7.0.202003110725-r.jar
52
+ - lib/java/jars/org.eclipse.jgit-5.9.0.202009080501-r.jar
53
+ - lib/java/jars/org.eclipse.jgit.ssh.jsch-5.8.0.202006091008-r.jar
53
54
  - lib/java/jars/slf4j-api-1.7.2.jar
54
55
  - lib/java/jars/slf4j-simple-1.7.12.jar
55
56
  - lib/repo.rb