rjgit 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/git.rb +64 -50
- data/lib/rjgit.rb +0 -1
- data/lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a2ed014e4552131dfa9a476830910bcb9bbd21
|
4
|
+
data.tar.gz: 8a87b56be6c11c9e0a3b408f38118d2890bc27b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
44
|
-
|
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
|
-
|
59
|
+
|
60
|
+
jcommits.map{ |jcommit| Commit.new(jrepo, jcommit) }
|
48
61
|
end
|
49
62
|
|
50
|
-
def follow_renames(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
pull_command.
|
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
data/lib/version.rb
CHANGED
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.
|
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-
|
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.
|
79
|
+
rubygems_version: 2.4.5
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: JRuby wrapper around the JGit library.
|