rjgit 0.3.7 → 0.3.8

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git.rb +35 -1
  3. data/lib/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9245b5d9f4861f6b4235bc629312460693b18a17
4
- data.tar.gz: 3aeafdf12b1f9c362317663d3a736daadb51dbc0
3
+ metadata.gz: 5f8f94f2128a3ee824c892fc4c2c6d9be1ba6de0
4
+ data.tar.gz: 2a9f7160306fbae9ab4995d9d5216906c35f070a
5
5
  SHA512:
6
- metadata.gz: db938a041e535a18e7a0aede4f017174c897e9809673f7777df5778df91bc6ff10fc72eb4014632220fedf5c1f91c5c5048deb5485a2905f297bef0b1a056237
7
- data.tar.gz: 02508bddd55f4d13bd51702abe64d9840f517f56b101b3c2b6aab9490d52e6117d4cad96a093208e5b947da3df51c8854b1638acfcdc67615f040528cf3f3452
6
+ metadata.gz: a3d13231efffbec59d78cb0225dfea6a8e4d03f18a526949f503192075acc80a978317bb8803cc20b771de0c72e74f131550aaf862674f422b0f555d8e6f80a5
7
+ data.tar.gz: ea070846441ec20a6c9eb3cdde196886c5f3ea6f34b7b5c4412ca657fbb76f3d9b3f2184778c18f6b71edc49ae8b9d8c1fb465e94b596801635d65e687b39ee7
data/lib/git.rb CHANGED
@@ -9,6 +9,8 @@ module RJGit
9
9
  import 'org.eclipse.jgit.api.RmCommand'
10
10
  import 'org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider'
11
11
  import 'org.eclipse.jgit.transport.RefSpec'
12
+ import 'org.eclipse.jgit.diff.RenameDetector'
13
+ import 'org.eclipse.jgit.diff.DiffEntry'
12
14
 
13
15
  class RubyGit
14
16
 
@@ -31,13 +33,45 @@ module RJGit
31
33
  logs.addPath(path) if path
32
34
  logs.setMaxCount(options[:max_count]) if options[:max_count]
33
35
  logs.setSkip(options[:skip]) if options[:skip]
36
+ jcommits = logs.call
34
37
  commits = Array.new
35
- logs.call.each do |jcommit|
38
+ jcommits.each do |jcommit|
36
39
  commits << Commit.new(jrepo, jcommit)
37
40
  end
41
+
42
+ if path && options[:follow]
43
+ jcommits = @jgit.log.add(ref).addPath(path).call
44
+ commits += follow_renames(jcommits, path)
45
+ end
46
+
38
47
  commits
39
48
  end
40
49
 
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
68
+ end
69
+ end
70
+ end
71
+ renames
72
+ end
73
+
74
+
41
75
  def branch_list
42
76
  branch = @jgit.branch_list
43
77
  array = Array.new
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RJGit
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
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.7
4
+ version: 0.3.8
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-01 00:00:00.000000000 Z
15
+ date: 2015-04-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mime-types