libdolt 0.9.0 → 0.10.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 -3
- data/lib/libdolt/repo_actions.rb +4 -4
- data/lib/libdolt/version.rb +1 -1
- data/test/libdolt/repo_actions_test.rb +16 -3
- data/test/libdolt/templates/refs_test.rb +4 -1
- data/views/refs.erb +2 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
libdolt (0.
|
4
|
+
libdolt (0.9.0)
|
5
5
|
em_pessimistic (~> 0.1)
|
6
6
|
em_rugged (~> 0.3)
|
7
7
|
eventmachine (~> 1.0)
|
8
8
|
htmlentities (~> 4.3)
|
9
9
|
json (~> 1.7)
|
10
|
-
makeup (~> 0)
|
10
|
+
makeup (~> 0.2)
|
11
11
|
mime-types (~> 1.19)
|
12
12
|
tzinfo (~> 0.3)
|
13
13
|
when (~> 0)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
github-markup (0.7.4)
|
27
27
|
htmlentities (4.3.1)
|
28
28
|
json (1.7.5)
|
29
|
-
makeup (0.
|
29
|
+
makeup (0.2.0)
|
30
30
|
github-markup (~> 0.7)
|
31
31
|
htmlentities (~> 4.3)
|
32
32
|
pygments.rb (~> 0.2)
|
data/lib/libdolt/repo_actions.rb
CHANGED
@@ -61,8 +61,8 @@ module Dolt
|
|
61
61
|
names = refs.map(&:name)
|
62
62
|
block.call(nil, {
|
63
63
|
:repository_slug => repo,
|
64
|
-
:tags =>
|
65
|
-
:heads =>
|
64
|
+
:tags => expand_refs(repository, names, :tags),
|
65
|
+
:heads => expand_refs(repository, names, :heads)
|
66
66
|
})
|
67
67
|
end
|
68
68
|
d.errback { |err| block.call(err, nil) }
|
@@ -96,9 +96,9 @@ module Dolt
|
|
96
96
|
}.merge(locals)
|
97
97
|
end
|
98
98
|
|
99
|
-
def
|
99
|
+
def expand_refs(repository, names, type)
|
100
100
|
names.select { |n| n =~ /#{type}/ }.map do |n|
|
101
|
-
n.sub(/^refs\/#{type}\//, "")
|
101
|
+
[n.sub(/^refs\/#{type}\//, ""), repository.rev_parse_oid_sync(n)]
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
data/lib/libdolt/version.rb
CHANGED
@@ -22,10 +22,15 @@ require "ostruct"
|
|
22
22
|
|
23
23
|
class Repository
|
24
24
|
attr_reader :name
|
25
|
-
def initialize(name)
|
25
|
+
def initialize(name)
|
26
|
+
@name = name
|
27
|
+
@refs = {}
|
28
|
+
end
|
29
|
+
|
26
30
|
def tree(ref, path); stub; end
|
27
31
|
def tree_entry(ref, path); stub; end
|
28
32
|
def rev_parse(rev); stub; end
|
33
|
+
def rev_parse_oid_sync(ref); @refs[ref] || nil; end
|
29
34
|
def blame(ref, path); stub; end
|
30
35
|
def log(ref, path, limit); stub; end
|
31
36
|
def refs; stub; end
|
@@ -35,6 +40,10 @@ class Repository
|
|
35
40
|
@deferred.resolve(blob)
|
36
41
|
end
|
37
42
|
|
43
|
+
def stub_ref(name, ref)
|
44
|
+
@refs[name] = ref
|
45
|
+
end
|
46
|
+
|
38
47
|
private
|
39
48
|
def stub
|
40
49
|
@deferred = When.defer
|
@@ -213,12 +222,16 @@ describe Dolt::RepoActions do
|
|
213
222
|
@actions.refs("gitorious") { |err, d| data = d }
|
214
223
|
|
215
224
|
repo = @resolver.resolved.last
|
225
|
+
repo.stub_ref("refs/tags/v0.2.0", "a" * 40)
|
226
|
+
repo.stub_ref("refs/tags/v0.2.1", "b" * 40)
|
227
|
+
repo.stub_ref("refs/heads/libgit2", "c" * 40)
|
228
|
+
repo.stub_ref("refs/heads/master", "d" * 40)
|
216
229
|
repo.resolve_promise(@refs)
|
217
230
|
|
218
231
|
expected = {
|
219
232
|
:repository_slug => "gitorious",
|
220
|
-
:heads => ["libgit2", "master"],
|
221
|
-
:tags => ["v0.2.1", "v0.2.0"]
|
233
|
+
:heads => [["libgit2", "c" * 40], ["master", "d" * 40]],
|
234
|
+
:tags => [["v0.2.1", "b" * 40], ["v0.2.0", "a" * 40]]
|
222
235
|
}
|
223
236
|
assert_equal expected, data
|
224
237
|
end
|
@@ -28,7 +28,10 @@ describe "refs template" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "renders JSON" do
|
31
|
-
data = {
|
31
|
+
data = {
|
32
|
+
"heads" => [["libgit2", "0123456"], ["master", "1234567"]],
|
33
|
+
"tags" => [["v2.1.0", "2345678"]]
|
34
|
+
}
|
32
35
|
html = @renderer.render(:refs, data)
|
33
36
|
|
34
37
|
assert_equal data, JSON.parse(html)
|
data/views/refs.erb
CHANGED
@@ -17,6 +17,6 @@
|
|
17
17
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
19
|
%>{
|
20
|
-
"heads": [<%= heads.map { |
|
21
|
-
"tags": [<%= tags.map { |
|
20
|
+
"heads": [<%= heads.map { |head| "[\"#{head.first}\", \"#{head.last}\"]" }.join(",") %>],
|
21
|
+
"tags": [<%= tags.map { |tag| "[\"#{tag.first}\", \"#{tag.last}\"]" }.join(",") %>]
|
22
22
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libdolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 10
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Johansen
|