libdolt 0.15.0 → 0.16.0
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.
- data/Gemfile.lock +3 -16
- data/Readme.md +2 -3
- data/lib/libdolt/git/archiver.rb +15 -40
- data/lib/libdolt/git/blame.rb +4 -0
- data/lib/libdolt/git/process.rb +44 -0
- data/lib/libdolt/git/repository.rb +56 -101
- data/lib/libdolt/git.rb +42 -0
- data/lib/libdolt/repo_actions.rb +28 -36
- data/lib/libdolt/version.rb +1 -1
- data/lib/libdolt.rb +1 -3
- data/libdolt.gemspec +1 -5
- data/test/libdolt/git/archiver_test.rb +28 -91
- data/test/libdolt/git/blame_test.rb +40 -4
- data/test/libdolt/git/commit_test.rb +1 -3
- data/test/libdolt/git/repository_test.rb +92 -171
- data/test/libdolt/repo_actions_test.rb +102 -144
- data/test/test_helper.rb +22 -2
- metadata +9 -71
data/Gemfile.lock
CHANGED
@@ -2,36 +2,25 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
libdolt (0.15.0)
|
5
|
-
em_pessimistic (~> 0.1)
|
6
|
-
em_rugged (~> 0.3)
|
7
|
-
eventmachine (~> 1.0)
|
8
5
|
htmlentities (~> 4.3)
|
9
6
|
json (~> 1.7)
|
10
7
|
makeup (~> 0.2)
|
11
8
|
mime-types (~> 1.19)
|
9
|
+
rugged (= 0.17.0.b6)
|
12
10
|
tzinfo (~> 0.3)
|
13
|
-
when (~> 0)
|
14
11
|
|
15
12
|
GEM
|
16
13
|
remote: http://rubygems.org/
|
17
14
|
specs:
|
18
|
-
em-minitest-spec (1.1.1)
|
19
|
-
eventmachine
|
20
|
-
em_pessimistic (0.1.2)
|
21
|
-
eventmachine (~> 1.0)
|
22
|
-
em_rugged (0.3.0)
|
23
|
-
eventmachine (~> 1.0)
|
24
|
-
rugged (= 0.17.0.b6)
|
25
|
-
eventmachine (1.0.0)
|
26
15
|
github-markup (0.7.5)
|
27
16
|
htmlentities (4.3.1)
|
28
|
-
json (1.7.
|
17
|
+
json (1.7.7)
|
29
18
|
makeup (0.3.0)
|
30
19
|
github-markup (~> 0.7)
|
31
20
|
htmlentities (~> 4.3)
|
32
21
|
pygments.rb (~> 0.2)
|
33
22
|
metaclass (0.0.1)
|
34
|
-
mime-types (1.
|
23
|
+
mime-types (1.21)
|
35
24
|
minitest (2.12.1)
|
36
25
|
mocha (0.13.1)
|
37
26
|
metaclass (~> 0.0.1)
|
@@ -46,14 +35,12 @@ GEM
|
|
46
35
|
tiltout (1.4.0)
|
47
36
|
tilt (~> 1.3)
|
48
37
|
tzinfo (0.3.35)
|
49
|
-
when (0.1.0)
|
50
38
|
yajl-ruby (1.1.0)
|
51
39
|
|
52
40
|
PLATFORMS
|
53
41
|
ruby
|
54
42
|
|
55
43
|
DEPENDENCIES
|
56
|
-
em-minitest-spec (~> 1.1)
|
57
44
|
libdolt!
|
58
45
|
minitest (~> 2.0)
|
59
46
|
mocha
|
data/Readme.md
CHANGED
@@ -25,9 +25,8 @@ To install `dolt` you need Ruby, RubyGems and Python development files. The
|
|
25
25
|
Python development files are required to support Pygments syntax highlighting.
|
26
26
|
|
27
27
|
Note: Dolt uses [libgit2](http://libgit2.github.com) and its Ruby bindings,
|
28
|
-
[Rugged](http://github.com/libgit2/rugged)
|
29
|
-
|
30
|
-
feasible. Currently, ``EMRugged`` relies on a version of `Rugged` that is not
|
28
|
+
[Rugged](http://github.com/libgit2/rugged) for Git access where
|
29
|
+
feasible. Currently, ``Dolt`` relies on a version of `Rugged` that is not
|
31
30
|
yet released, so you have to build it yourself.
|
32
31
|
[See em-rugged instructions](http://github.com/cjohansen/em-rugged).
|
33
32
|
|
data/lib/libdolt/git/archiver.rb
CHANGED
@@ -15,21 +15,14 @@
|
|
15
15
|
# You should have received a copy of the GNU Affero General Public License
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
#++
|
18
|
-
require "when"
|
19
|
-
require "eventmachine"
|
20
|
-
require "em_pessimistic"
|
21
18
|
require "fileutils"
|
19
|
+
require "shellwords"
|
20
|
+
require "libdolt/git"
|
22
21
|
|
23
22
|
module Dolt
|
24
23
|
module Git
|
25
24
|
class Archiver
|
26
25
|
def initialize(work_dir, cache_dir)
|
27
|
-
# A hash of currently processing archiving jobs. It contains tuples of
|
28
|
-
# "#{repo.id}-#{oid}-#{format}" => promises representing the eventual
|
29
|
-
# completion of archiving tasks. When an archiving task is completed,
|
30
|
-
# its promise is removed from the hash. Previously generated tarballs
|
31
|
-
# can be found on disk.
|
32
|
-
@processing = {}
|
33
26
|
@work_dir = work_dir
|
34
27
|
@cache_dir = cache_dir
|
35
28
|
end
|
@@ -42,40 +35,23 @@ module Dolt
|
|
42
35
|
# format - A symbol. If it is not :zip, tar.gz is assumed.
|
43
36
|
def archive(repo, oid, format = :tgz)
|
44
37
|
filename = cache_path(repo, oid, format)
|
45
|
-
return
|
46
|
-
|
47
|
-
return pending if pending
|
48
|
-
start_process(repo, oid, format)
|
38
|
+
return filename if File.exists?(filename)
|
39
|
+
archive_repo(repo, oid, format)
|
49
40
|
end
|
50
41
|
|
51
42
|
private
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def start_process(repo, oid, format)
|
61
|
-
@processing[process_id(repo, oid, format)] = When.defer do |d|
|
62
|
-
p = EMPessimistic::DeferrableChildProcess.open(cmd(repo, oid, format))
|
63
|
-
|
64
|
-
p.callback do |output, status|
|
65
|
-
filename = cache_path(repo, oid, format)
|
66
|
-
FileUtils.mv(work_path(repo, oid, format), filename)
|
67
|
-
d.resolve(filename)
|
68
|
-
end
|
69
|
-
|
70
|
-
p.errback do |output, status|
|
71
|
-
d.reject(Exception.new(output))
|
72
|
-
end
|
73
|
-
end
|
43
|
+
def archive_repo(repo, oid, format)
|
44
|
+
process = Dolt::Git.shell(cmd(repo, oid, format))
|
45
|
+
raise process.exception if !process.success?
|
46
|
+
filename = cache_path(repo, oid, format)
|
47
|
+
FileUtils.mv(work_path(repo, oid, format), filename)
|
48
|
+
filename
|
74
49
|
end
|
75
50
|
|
76
51
|
def cmd(repository, oid, format)
|
77
52
|
path_segment = repository.path_segment.gsub(/\//, "-")
|
78
|
-
|
53
|
+
git = Dolt::Git.binary
|
54
|
+
cmd = "sh -c '#{git} --git-dir #{repository.full_repository_path} archive "
|
79
55
|
cmd += "--prefix='#{u(path_segment)}/' --format="
|
80
56
|
wpath = u(work_path(repository, oid, format))
|
81
57
|
cmd + (format.to_s == "zip" ? "zip #{u(oid)} > #{wpath}" : "tar #{u(oid)} | gzip -m > #{wpath}") + "'"
|
@@ -90,17 +66,16 @@ module Dolt
|
|
90
66
|
end
|
91
67
|
|
92
68
|
def basename(repository, oid, format)
|
93
|
-
path_segment = repository.path_segment.gsub(/\//, "-")
|
94
|
-
"#{path_segment}
|
69
|
+
path_segment = "#{repository.path_segment}-#{oid}".gsub(/\//, "-")
|
70
|
+
"#{path_segment}.#{ext(format)}"
|
95
71
|
end
|
96
72
|
|
97
73
|
def ext(format)
|
98
74
|
format.to_s == "zip" ? "zip" : "tar.gz"
|
99
75
|
end
|
100
76
|
|
101
|
-
# Unquote a string by stripping off any single or double quotes
|
102
77
|
def u(string)
|
103
|
-
|
78
|
+
Shellwords.escape(string)
|
104
79
|
end
|
105
80
|
end
|
106
81
|
end
|
data/lib/libdolt/git/blame.rb
CHANGED
@@ -19,6 +19,8 @@ require "tzinfo"
|
|
19
19
|
|
20
20
|
module Dolt
|
21
21
|
module Git
|
22
|
+
class InvalidBlameFormat < Exception; end
|
23
|
+
|
22
24
|
class Blame
|
23
25
|
attr_reader :chunks
|
24
26
|
|
@@ -53,6 +55,8 @@ module Dolt
|
|
53
55
|
end
|
54
56
|
|
55
57
|
chunks
|
58
|
+
rescue Exception => error
|
59
|
+
raise InvalidBlameFormat.new("Failed parsing Procelain: #{error.message}")
|
56
60
|
end
|
57
61
|
|
58
62
|
def is_header?(line)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#--
|
3
|
+
# Copyright (C) 2013 Gitorious AS
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Affero General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#++
|
18
|
+
|
19
|
+
module Dolt
|
20
|
+
module Git
|
21
|
+
class Process
|
22
|
+
attr_reader :stdin, :stdout, :stderr
|
23
|
+
|
24
|
+
def initialize(stdin, stdout, stderr, process_status)
|
25
|
+
@stdin = stdin
|
26
|
+
@stdout = stdout
|
27
|
+
@stderr = stderr
|
28
|
+
@process_status = process_status
|
29
|
+
end
|
30
|
+
|
31
|
+
def success?
|
32
|
+
@process_status.success?
|
33
|
+
end
|
34
|
+
|
35
|
+
def exit_code
|
36
|
+
@process_status.exitstatus
|
37
|
+
end
|
38
|
+
|
39
|
+
def exception
|
40
|
+
Exception.new(stderr.read)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#--
|
3
|
-
# Copyright (C) 2012 Gitorious AS
|
3
|
+
# Copyright (C) 2012-2013 Gitorious AS
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Affero General Public License as published by
|
@@ -15,53 +15,45 @@
|
|
15
15
|
# You should have received a copy of the GNU Affero General Public License
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
#++
|
18
|
-
require "
|
19
|
-
require "
|
18
|
+
require "rugged"
|
19
|
+
require "libdolt/git"
|
20
20
|
require "libdolt/git/blame"
|
21
21
|
require "libdolt/git/commit"
|
22
22
|
require "libdolt/git/submodule"
|
23
23
|
require "libdolt/git/tree"
|
24
|
-
require "when"
|
25
24
|
|
26
25
|
module Dolt
|
27
26
|
module Git
|
28
|
-
class Repository
|
29
|
-
def
|
30
|
-
|
31
|
-
gm = rev_parse("#{ref}:.gitmodules")
|
32
|
-
gm.callback do |config|
|
33
|
-
d.resolve(Dolt::Git::Submodule.parse_config(config.content))
|
34
|
-
end
|
35
|
-
# Fails if .gitmodules cannot be found, which means no submodules
|
36
|
-
gm.errback { |err| d.resolve([]) }
|
37
|
-
d
|
27
|
+
class Repository
|
28
|
+
def initialize(root)
|
29
|
+
@repo = Rugged::Repository.new(root)
|
38
30
|
end
|
39
31
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
def bare?; @repo.bare?; end
|
33
|
+
def path; @repo.path; end
|
34
|
+
def rev_parse(*args); @repo.rev_parse(*args); end
|
35
|
+
|
36
|
+
def submodules(ref)
|
37
|
+
config = rev_parse("#{ref}:.gitmodules")
|
38
|
+
Dolt::Git::Submodule.parse_config(config.content)
|
39
|
+
rescue Rugged::IndexerError => err
|
40
|
+
# Raised if .gitmodules cannot be found, which means no submodules
|
41
|
+
[]
|
46
42
|
end
|
47
43
|
|
48
44
|
def tree(ref, path)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
if !object.is_a?(Rugged::Tree)
|
53
|
-
next d.reject(StandardError.new("Not a tree"))
|
54
|
-
end
|
55
|
-
annotate_tree(d, ref, path, object)
|
56
|
-
end
|
57
|
-
rp.errback { |err| d.reject(err) }
|
58
|
-
end
|
45
|
+
object = rev_parse("#{ref}:#{path}")
|
46
|
+
raise StandardError.new("Not a tree") if !object.is_a?(Rugged::Tree)
|
47
|
+
annotate_tree(ref, path, object)
|
59
48
|
end
|
60
49
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
50
|
+
def tree_entry(ref, path)
|
51
|
+
annotate_tree(ref, path, rev_parse("#{ref}:#{path}"))
|
52
|
+
end
|
53
|
+
|
54
|
+
def blame(ref, blob_path)
|
55
|
+
process = Dolt::Git.git(path, "blame -l -t -p #{ref} -- #{blob_path}")
|
56
|
+
Dolt::Git::Blame.parse_porcelain(process.stdout.read)
|
65
57
|
end
|
66
58
|
|
67
59
|
def log(ref, path, limit)
|
@@ -69,98 +61,61 @@ module Dolt
|
|
69
61
|
end
|
70
62
|
|
71
63
|
def tree_history(ref, path, limit = 1)
|
72
|
-
|
73
|
-
rp = rev_parse("#{ref}:#{path}")
|
74
|
-
rp.errback { |err| d.reject(err) }
|
75
|
-
rp.callback do |tree|
|
76
|
-
if tree.class != Rugged::Tree
|
77
|
-
message = "#{ref}:#{path} is not a tree (#{tree.class.to_s})"
|
78
|
-
next d.reject(Exception.new(message))
|
79
|
-
end
|
64
|
+
tree = rev_parse("#{ref}:#{path}")
|
80
65
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
66
|
+
if tree.class != Rugged::Tree
|
67
|
+
message = "#{ref}:#{path} is not a tree (#{tree.class.to_s})"
|
68
|
+
raise Exception.new(message)
|
85
69
|
end
|
70
|
+
|
71
|
+
annotate_history(path || "./", ref, tree, limit)
|
86
72
|
end
|
87
73
|
|
88
74
|
def readme(ref)
|
89
|
-
|
90
|
-
|
91
|
-
t.callback do |tree|
|
92
|
-
d.resolve(tree.entries.select do |e|
|
93
|
-
e[:type] == :blob && e[:name].match(/readme/i)
|
94
|
-
end)
|
95
|
-
end
|
96
|
-
t.errback { |err| d.resolve([]) }
|
75
|
+
tree(ref, "").entries.select do |e|
|
76
|
+
e[:type] == :blob && e[:name].match(/readme/i)
|
97
77
|
end
|
78
|
+
rescue Exception => err
|
79
|
+
[]
|
98
80
|
end
|
99
81
|
|
100
82
|
private
|
101
83
|
def entry_history(ref, entry, limit)
|
102
|
-
|
103
|
-
|
104
|
-
end
|
84
|
+
process = Dolt::Git.git(path, "log -n #{limit} #{ref} -- #{entry}")
|
85
|
+
Dolt::Git::Commit.parse_log(process.stdout.read)
|
105
86
|
end
|
106
87
|
|
107
|
-
def
|
108
|
-
d = When.defer
|
88
|
+
def annotate_history(path, ref, entries, limit)
|
109
89
|
resolve = lambda { |p| path == "" ? p : File.join(path, p) }
|
110
|
-
|
111
|
-
|
112
|
-
end)
|
113
|
-
progress.errback { |e| d.reject(e) }
|
114
|
-
progress.callback do |history|
|
115
|
-
d.resolve(entries.map { |e| e.merge({ :history => history.shift }) })
|
90
|
+
entries.map do |e|
|
91
|
+
e.merge(:history => entry_history(ref, resolve.call(e[:name]), limit))
|
116
92
|
end
|
117
|
-
d
|
118
93
|
end
|
119
94
|
|
120
|
-
def annotate_tree(
|
95
|
+
def annotate_tree(ref, path, object)
|
121
96
|
if object.class.to_s.match(/Blob/) || !object.find { |e| e[:type].nil? }
|
122
|
-
return
|
97
|
+
return object
|
123
98
|
end
|
124
99
|
|
125
|
-
annotate_submodules(
|
100
|
+
annotate_submodules(ref, path, object)
|
126
101
|
end
|
127
102
|
|
128
|
-
def annotate_submodules(
|
129
|
-
submodules(ref)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
103
|
+
def annotate_submodules(ref, path, tree)
|
104
|
+
modules = submodules(ref)
|
105
|
+
|
106
|
+
entries = tree.entries.map do |entry|
|
107
|
+
if entry[:type].nil?
|
108
|
+
mod = path == "" ? entry[:name] : File.join(path, entry[:name])
|
109
|
+
meta = modules.find { |s| s[:path] == mod }
|
110
|
+
if meta
|
111
|
+
entry[:type] = :submodule
|
112
|
+
entry[:url] = meta[:url]
|
138
113
|
end
|
139
|
-
entry
|
140
114
|
end
|
141
|
-
|
142
|
-
deferrable.resolve(Dolt::Git::Tree.new(tree.oid, entries))
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def deferred_method(cmd, &block)
|
147
|
-
d = When.defer
|
148
|
-
cmd = git(cmd)
|
149
|
-
p = EMPessimistic::DeferrableChildProcess.open(cmd)
|
150
|
-
|
151
|
-
p.callback do |output, status|
|
152
|
-
d.resolve(block.call(output, status))
|
115
|
+
entry
|
153
116
|
end
|
154
117
|
|
155
|
-
|
156
|
-
d.reject(stderr)
|
157
|
-
end
|
158
|
-
|
159
|
-
d
|
160
|
-
end
|
161
|
-
|
162
|
-
def git(cmd)
|
163
|
-
"git --git-dir #{path} #{cmd}"
|
118
|
+
Dolt::Git::Tree.new(tree.oid, entries)
|
164
119
|
end
|
165
120
|
end
|
166
121
|
end
|
data/lib/libdolt/git.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#--
|
3
|
+
# Copyright (C) 2013 Gitorious AS
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Affero General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#++
|
18
|
+
require "open3"
|
19
|
+
require "libdolt/git/process"
|
20
|
+
require "shellwords"
|
21
|
+
|
22
|
+
module Dolt
|
23
|
+
module Git
|
24
|
+
def self.shell(command)
|
25
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
26
|
+
Dolt::Git::Process.new(stdin, stdout, stderr, $?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.git(git_dir, command)
|
30
|
+
args = Shellwords.join(command.split(" "))
|
31
|
+
shell("#{binary} --git-dir #{git_dir} #{args}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.binary
|
35
|
+
@binary ||= "git"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.binary=(path)
|
39
|
+
@binary = path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/libdolt/repo_actions.rb
CHANGED
@@ -28,50 +28,43 @@ module Dolt
|
|
28
28
|
@archiver = archiver
|
29
29
|
end
|
30
30
|
|
31
|
-
def blob(repo, ref, path
|
32
|
-
repo_action(repo, ref, path, :blob, :rev_parse, "#{ref}:#{path}"
|
31
|
+
def blob(repo, ref, path)
|
32
|
+
repo_action(repo, ref, path, :blob, :rev_parse, "#{ref}:#{path}")
|
33
33
|
end
|
34
34
|
|
35
|
-
def tree(repo, ref, path
|
36
|
-
repo_action(repo, ref, path, :tree, :tree, ref, path
|
35
|
+
def tree(repo, ref, path)
|
36
|
+
repo_action(repo, ref, path, :tree, :tree, ref, path)
|
37
37
|
end
|
38
38
|
|
39
|
-
def tree_entry(repo, ref, path
|
39
|
+
def tree_entry(repo, ref, path)
|
40
40
|
repository = resolve_repository(repo)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
block.call(nil, tpl_data(repository, ref, path, { key => result, :type => key }))
|
45
|
-
end
|
46
|
-
d.errback { |err| block.call(err, nil) }
|
41
|
+
result = repository.tree_entry(ref, path)
|
42
|
+
key = result.class.to_s.match(/Blob/) ? :blob : :tree
|
43
|
+
tpl_data(repository, ref, path, { key => result, :type => key })
|
47
44
|
end
|
48
45
|
|
49
|
-
def blame(repo, ref, path
|
50
|
-
repo_action(repo, ref, path, :blame, :blame, ref, path
|
46
|
+
def blame(repo, ref, path)
|
47
|
+
repo_action(repo, ref, path, :blame, :blame, ref, path)
|
51
48
|
end
|
52
49
|
|
53
|
-
def history(repo, ref, path, count
|
54
|
-
repo_action(repo, ref, path, :commits, :log, ref, path, count
|
50
|
+
def history(repo, ref, path, count)
|
51
|
+
repo_action(repo, ref, path, :commits, :log, ref, path, count)
|
55
52
|
end
|
56
53
|
|
57
|
-
def refs(repo
|
54
|
+
def refs(repo)
|
58
55
|
repository = resolve_repository(repo)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
:heads => expand_refs(repository, names, :heads)
|
65
|
-
}.merge(repository.to_hash))
|
66
|
-
end
|
67
|
-
d.errback { |err| block.call(err, nil) }
|
56
|
+
names = repository.refs.map(&:name)
|
57
|
+
{
|
58
|
+
:tags => expand_refs(repository, names, :tags),
|
59
|
+
:heads => expand_refs(repository, names, :heads)
|
60
|
+
}.merge(repository.to_hash)
|
68
61
|
end
|
69
62
|
|
70
|
-
def tree_history(repo, ref, path, count
|
71
|
-
repo_action(repo, ref, path, :tree, :tree_history, ref, path, count
|
63
|
+
def tree_history(repo, ref, path, count)
|
64
|
+
repo_action(repo, ref, path, :tree, :tree_history, ref, path, count)
|
72
65
|
end
|
73
66
|
|
74
|
-
def archive(repo, ref, format
|
67
|
+
def archive(repo, ref, format)
|
75
68
|
repository = resolve_repository(repo)
|
76
69
|
d = @archiver.archive(repository, ref, format)
|
77
70
|
d.callback { |filename| block.call(nil, filename) }
|
@@ -87,19 +80,18 @@ module Dolt
|
|
87
80
|
end
|
88
81
|
|
89
82
|
def rev_parse_oid(repo, ref)
|
90
|
-
resolve_repository(repo).
|
83
|
+
resolve_repository(repo).rev_parse_oid(ref)
|
91
84
|
end
|
92
85
|
|
93
86
|
private
|
94
87
|
def repo_resolver; @repo_resolver; end
|
95
88
|
|
96
|
-
def repo_action(repo, ref, path, data, method, *args
|
89
|
+
def repo_action(repo, ref, path, data, method, *args)
|
97
90
|
repository = resolve_repository(repo)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
d.errback { |err| block.call(err, nil) }
|
91
|
+
|
92
|
+
tpl_data(repository, ref, path, {
|
93
|
+
data => repository.send(method, *args)
|
94
|
+
})
|
103
95
|
end
|
104
96
|
|
105
97
|
def tpl_data(repo, ref, path, locals = {})
|
@@ -109,7 +101,7 @@ module Dolt
|
|
109
101
|
|
110
102
|
def expand_refs(repository, names, type)
|
111
103
|
names.select { |n| n =~ /#{type}/ }.map do |n|
|
112
|
-
[n.sub(/^refs\/#{type}\//, ""), repository.
|
104
|
+
[n.sub(/^refs\/#{type}\//, ""), repository.rev_parse_oid(n)]
|
113
105
|
end
|
114
106
|
end
|
115
107
|
end
|
data/lib/libdolt/version.rb
CHANGED
data/lib/libdolt.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
1
|
# encoding: utf-8
|
3
2
|
#--
|
4
|
-
# Copyright (C) 2012 Gitorious AS
|
3
|
+
# Copyright (C) 2012-2013 Gitorious AS
|
5
4
|
#
|
6
5
|
# This program is free software: you can redistribute it and/or modify
|
7
6
|
# it under the terms of the GNU Affero General Public License as published by
|
@@ -16,7 +15,6 @@
|
|
16
15
|
# You should have received a copy of the GNU Affero General Public License
|
17
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
17
|
#++
|
19
|
-
|
20
18
|
require "libdolt/version"
|
21
19
|
require "libdolt/disk_repo_resolver"
|
22
20
|
require "libdolt/gitorious_repo_resolver"
|
data/libdolt.gemspec
CHANGED
@@ -13,10 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "libdolt"
|
15
15
|
|
16
|
-
s.add_dependency "
|
17
|
-
s.add_dependency "when", "~>0"
|
18
|
-
s.add_dependency "em_pessimistic", "~>0.1"
|
19
|
-
s.add_dependency "em_rugged", "~> 0.3"
|
16
|
+
s.add_dependency "rugged", "0.17.0.b6"
|
20
17
|
s.add_dependency "tzinfo", "~> 0.3"
|
21
18
|
s.add_dependency "makeup", "~>0.2"
|
22
19
|
s.add_dependency "htmlentities", "~> 4.3"
|
@@ -24,7 +21,6 @@ Gem::Specification.new do |s|
|
|
24
21
|
s.add_dependency "mime-types", "~> 1.19"
|
25
22
|
|
26
23
|
s.add_development_dependency "minitest", "~> 2.0"
|
27
|
-
s.add_development_dependency "em-minitest-spec", "~> 1.1"
|
28
24
|
s.add_development_dependency "rake", "~> 0.9"
|
29
25
|
s.add_development_dependency "redcarpet", "2.2.0"
|
30
26
|
s.add_development_dependency "tiltout", "~>1.4"
|