rjgit 0.3.9 → 0.3.10

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git.rb +64 -50
  3. data/lib/rjgit.rb +0 -1
  4. data/lib/version.rb +1 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85c0a3a90f26f105a97cc8c2e8c1635102f5ea47
4
- data.tar.gz: 653c8baf0fc37d38abbdd142247419a91e1def7d
3
+ metadata.gz: c1a2ed014e4552131dfa9a476830910bcb9bbd21
4
+ data.tar.gz: 8a87b56be6c11c9e0a3b408f38118d2890bc27b3
5
5
  SHA512:
6
- metadata.gz: 37fcd607f511dfe10409215b850b07c035771a9fa5067a2af45669d0c7e199388c403d954aae10493c116c6150cadf31a9bed0f5dd2c1153f91ca28f5dc649d8
7
- data.tar.gz: cb431171a963dd00b98fc25b05890c29db6d2dfd0fed90a06618af8af216826f328ef86c3903e3985a6b1d6500f270afa501293b22b01db56e48c1cecf121707
6
+ metadata.gz: 6a06ea1e11b4430f5ab2942780fcf2dcb3b049ef7cb35e5e6a521c569bbd0fc3f0d700fd9855c386f8a18f30f543e0f0049110bf4bb427a08aaa843864f9a9c9
7
+ data.tar.gz: 24d10328ac8a7e7b87edd3ff3ae72362190ca9ed417ae42711c498e848a84f73a9dc9ece84c8c6596e5a0823516f393ddbc6096c1f91ca7f79ba5a3ab974ab37
data/lib/git.rb CHANGED
@@ -11,6 +11,7 @@ module RJGit
11
11
  import 'org.eclipse.jgit.transport.RefSpec'
12
12
  import 'org.eclipse.jgit.diff.RenameDetector'
13
13
  import 'org.eclipse.jgit.diff.DiffEntry'
14
+ import 'org.eclipse.jgit.treewalk.filter.PathFilter'
14
15
 
15
16
  class RubyGit
16
17
 
@@ -27,48 +28,58 @@ module RJGit
27
28
  end
28
29
 
29
30
  def log(path = nil, revstring = Constants::HEAD, options = {})
30
- logs = @jgit.log
31
31
  ref = jrepo.resolve(revstring)
32
- logs.add(ref)
33
- logs.addPath(path) if path
34
- logs.setMaxCount(options[:max_count]) if options[:max_count]
35
- logs.setSkip(options[:skip]) if options[:skip]
36
- jcommits = logs.call
37
- commits = Array.new
38
- jcommits.each do |jcommit|
39
- commits << Commit.new(jrepo, jcommit)
40
- end
32
+ jcommits = Array.new
41
33
 
42
34
  if path && options[:follow]
43
- jcommits = @jgit.log.add(ref).addPath(path).call
44
- commits += follow_renames(jcommits, path)
35
+ current_path = path
36
+ start = nil
37
+ loop do
38
+ logs = @jgit.log.add(ref).addPath(current_path).call
39
+ logs.each do |jcommit|
40
+ next if jcommits.include?(jcommit)
41
+ jcommits << jcommit
42
+ start = jcommit
43
+ end
44
+ current_path = follow_renames(start, current_path)
45
+ break if current_path.nil?
46
+ end
47
+
48
+ else
49
+ logs = @jgit.log
50
+ logs.add(ref)
51
+ logs.addPath(path) if path
52
+ logs.setMaxCount(options[:max_count]) if options[:max_count]
53
+ logs.setSkip(options[:skip]) if options[:skip]
54
+ # These options need tests
55
+ # logs.addRange(options[:since], options[:until]) if (options[:since] && options[:until])
56
+ # logs.not(options[:not]) if options[:not]
57
+ jcommits = logs.call
45
58
  end
46
-
47
- commits
59
+
60
+ jcommits.map{ |jcommit| Commit.new(jrepo, jcommit) }
48
61
  end
49
62
 
50
- def follow_renames(jcommits, path)
51
- renames = Array.new
52
- jcommits.each do |jcommit|
53
- all_commits = @jgit.log.add(jcommit).call
54
- all_commits.each do |jcommit_prev|
55
- tree_start = jcommit.getTree
56
- tree_prev = jcommit_prev.getTree
57
- treewalk = TreeWalk.new(jrepo)
58
- treewalk.addTree(tree_prev)
59
- treewalk.addTree(tree_start)
60
- treewalk.setRecursive(true)
61
- rename_detector = RenameDetector.new(jrepo)
62
- rename_detector.addAll(DiffEntry.scan(treewalk))
63
- diff_entries = rename_detector.compute
64
- diff_entries.each do |entry|
65
- if ((entry.getChangeType == DiffEntry::ChangeType::RENAME || entry.getChangeType == DiffEntry::ChangeType::COPY) && entry.getNewPath.match(path))
66
- renames << Commit.new(jrepo, jcommit_prev)
67
- end
63
+ def follow_renames(jcommit, path)
64
+ commits = @jgit.log.add(jcommit).call
65
+ commits.each do |jcommit_prev|
66
+ tree_start = jcommit.getTree
67
+ tree_prev = jcommit_prev.getTree
68
+ treewalk = TreeWalk.new(jrepo)
69
+ #treewalk.setFilter(PathFilter.create(File.dirname(path)))
70
+ treewalk.addTree(tree_prev)
71
+ treewalk.addTree(tree_start)
72
+ treewalk.setRecursive(true)
73
+ rename_detector = RenameDetector.new(jrepo)
74
+ rename_detector.addAll(DiffEntry.scan(treewalk))
75
+ diff_entries = rename_detector.compute
76
+ diff_entries.each do |entry|
77
+ if ((entry.getChangeType == DiffEntry::ChangeType::RENAME || entry.getChangeType == DiffEntry::ChangeType::COPY) && entry.getNewPath.match(path))
78
+ return entry.getOldPath
68
79
  end
69
80
  end
70
81
  end
71
- renames
82
+ return nil
72
83
  end
73
84
 
74
85
 
@@ -251,28 +262,31 @@ module RJGit
251
262
  push_command.call
252
263
  end
253
264
 
254
- def push(remote, refs = [], options = {})
255
- if(refs.size > 0)
265
+ def push(remote = nil, refs = [], options = {})
266
+ push_command = @jgit.push
267
+ push_command.set_dry_run(true) if options[:dryrun]
268
+ push_command.set_remote(remote) if remote
269
+ if(refs.to_a.size > 0)
256
270
  refs.map!{|ref| RefSpec.new(ref)}
257
- push_command = @jgit.push
258
- push_command.set_dry_run(true) if options[:dryrun]
259
- push_command.set_remote(remote)
260
271
  push_command.set_ref_specs(refs)
261
- if options[:username]
262
- push_command.set_credentials_provider(UsernamePasswordCredentialsProvider.new(options[:username], options[:password]))
263
- end
264
- push_command.call
265
272
  end
273
+ if options[:username]
274
+ push_command.set_credentials_provider(UsernamePasswordCredentialsProvider.new(options[:username], options[:password]))
275
+ end
276
+ push_command.call
266
277
  end
267
278
 
268
- def pull(options = {})
269
- pull_command = @jgit.pull
270
- pull_command.set_dry_run(true) if options[:dryrun]
271
- pull_command.set_rebase(options[:rebase]) if options[:rebase]
272
- if options[:username]
273
- pull_command.set_credentials_provider(UsernamePasswordCredentialsProvider.new(options[:username], options[:password]))
274
- end
275
- pull_command.call
279
+ def pull(remote = nil, remote_ref = nil, options = {})
280
+ pull_command = @jgit.pull
281
+ pull_command.set_dry_run(true) if options[:dryrun]
282
+ pull_command.set_rebase(options[:rebase]) if options[:rebase]
283
+ pull_command.set_remote(remote) if remote
284
+ pull_command.set_remote_branch_name(remote_ref) if remote_ref
285
+ if options[:username]
286
+ pull_command.set_credentials_provider(UsernamePasswordCredentialsProvider.new(options[:username], options[:password]))
287
+ end
288
+ pull_command.call
276
289
  end
290
+
277
291
  end
278
292
  end
data/lib/rjgit.rb CHANGED
@@ -334,7 +334,6 @@ module RJGit
334
334
 
335
335
  @treebuilder.object_inserter.release
336
336
  @current_tree = new_tree
337
- @treemap = {}
338
337
  log = @treebuilder.log
339
338
  @treebuilder.init_log
340
339
  sha = ObjectId.to_string(new_head)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RJGit
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
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: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Engelen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-04-06 00:00:00.000000000 Z
15
+ date: 2015-04-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mime-types
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.2.2
79
+ rubygems_version: 2.4.5
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: JRuby wrapper around the JGit library.