dolt 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/dolt.gemspec +1 -1
- data/lib/dolt/sinatra/actions.rb +18 -17
- data/test/dolt/sinatra/actions_test.rb +64 -0
- data/test/test_helper.rb +1 -0
- metadata +22 -21
data/dolt.gemspec
CHANGED
data/lib/dolt/sinatra/actions.rb
CHANGED
@@ -53,24 +53,24 @@ module Dolt
|
|
53
53
|
HTML
|
54
54
|
end
|
55
55
|
|
56
|
-
def raw(repo, ref, path)
|
56
|
+
def raw(repo, ref, path, custom_data = {})
|
57
57
|
if oid = lookup_ref_oid(repo, ref)
|
58
58
|
redirect(raw_url(repo, oid, path)) and return
|
59
59
|
end
|
60
60
|
|
61
|
-
blob(repo, ref, path, {
|
61
|
+
blob(repo, ref, path, custom_data, {
|
62
62
|
:template => :raw,
|
63
63
|
:content_type => "text/plain",
|
64
64
|
:template_options => { :layout => nil }
|
65
65
|
})
|
66
66
|
end
|
67
67
|
|
68
|
-
def blob(repo, ref, path, options = { :template => :blob })
|
68
|
+
def blob(repo, ref, path, custom_data = {}, options = { :template => :blob })
|
69
69
|
if oid = lookup_ref_oid(repo, ref)
|
70
70
|
redirect(blob_url(repo, oid, path)) and return
|
71
71
|
end
|
72
72
|
|
73
|
-
data = actions.blob(repo, u(ref), path)
|
73
|
+
data = (custom_data || {}).merge(actions.blob(repo, u(ref), path))
|
74
74
|
blob = data[:blob]
|
75
75
|
return redirect(tree_url(repo, ref, path)) if blob.class.to_s !~ /\bBlob/
|
76
76
|
add_headers(response, options.merge(:ref => ref))
|
@@ -80,12 +80,12 @@ module Dolt
|
|
80
80
|
error(err, repo, ref)
|
81
81
|
end
|
82
82
|
|
83
|
-
def tree(repo, ref, path)
|
83
|
+
def tree(repo, ref, path, custom_data = {})
|
84
84
|
if oid = lookup_ref_oid(repo, ref)
|
85
85
|
redirect(tree_url(repo, oid, path)) and return
|
86
86
|
end
|
87
87
|
|
88
|
-
data = actions.tree(repo, u(ref), path)
|
88
|
+
data = (custom_data || {}).merge(actions.tree(repo, u(ref), path))
|
89
89
|
tree = data[:tree]
|
90
90
|
return redirect(blob_url(repo, ref, path)) if tree.class.to_s !~ /\bTree/
|
91
91
|
add_headers(response, :ref => ref)
|
@@ -94,56 +94,56 @@ module Dolt
|
|
94
94
|
error(err, repo, ref)
|
95
95
|
end
|
96
96
|
|
97
|
-
def tree_entry(repo, ref, path)
|
97
|
+
def tree_entry(repo, ref, path, custom_data = {})
|
98
98
|
if oid = lookup_ref_oid(repo, ref)
|
99
99
|
redirect(tree_entry_url(repo, oid, path)) and return
|
100
100
|
end
|
101
101
|
|
102
|
-
data = actions.tree_entry(repo, u(ref), path)
|
102
|
+
data = (custom_data || {}).merge(actions.tree_entry(repo, u(ref), path))
|
103
103
|
add_headers(response, :ref => ref)
|
104
104
|
body(renderer.render(data.key?(:tree) ? :tree : :blob, data))
|
105
105
|
rescue Exception => err
|
106
106
|
error(err, repo, ref)
|
107
107
|
end
|
108
108
|
|
109
|
-
def blame(repo, ref, path)
|
109
|
+
def blame(repo, ref, path, custom_data = {})
|
110
110
|
if oid = lookup_ref_oid(repo, ref)
|
111
111
|
redirect(blame_url(repo, oid, path)) and return
|
112
112
|
end
|
113
113
|
|
114
|
-
data = actions.blame(repo, u(ref), path)
|
114
|
+
data = (custom_data || {}).merge(actions.blame(repo, u(ref), path))
|
115
115
|
add_headers(response, :ref => ref)
|
116
116
|
body(renderer.render(:blame, data))
|
117
117
|
rescue Exception => err
|
118
118
|
error(err, repo, ref)
|
119
119
|
end
|
120
120
|
|
121
|
-
def history(repo, ref, path, count)
|
121
|
+
def history(repo, ref, path, count, custom_data = {})
|
122
122
|
if oid = lookup_ref_oid(repo, ref)
|
123
123
|
redirect(history_url(repo, oid, path)) and return
|
124
124
|
end
|
125
125
|
|
126
|
-
data = actions.history(repo, u(ref), path, count)
|
126
|
+
data = (custom_data || {}).merge(actions.history(repo, u(ref), path, count))
|
127
127
|
add_headers(response, :ref => ref)
|
128
128
|
body(renderer.render(:commits, data))
|
129
129
|
rescue Exception => err
|
130
130
|
error(err, repo, ref)
|
131
131
|
end
|
132
132
|
|
133
|
-
def refs(repo)
|
134
|
-
data = actions.refs(repo)
|
133
|
+
def refs(repo, custom_data = {})
|
134
|
+
data = (custom_data || {}).merge(actions.refs(repo))
|
135
135
|
add_headers(response, :content_type => "application/json")
|
136
136
|
body(renderer.render(:refs, data, :layout => nil))
|
137
137
|
rescue Exception => err
|
138
138
|
error(err, repo, nil)
|
139
139
|
end
|
140
140
|
|
141
|
-
def tree_history(repo, ref, path, count = 1)
|
141
|
+
def tree_history(repo, ref, path, count = 1, custom_data = {})
|
142
142
|
if oid = lookup_ref_oid(repo, ref)
|
143
143
|
redirect(tree_history_url(repo, oid, path)) and return
|
144
144
|
end
|
145
145
|
|
146
|
-
data = actions.tree_history(repo, u(ref), path, count)
|
146
|
+
data = (custom_data || {}).merge(actions.tree_history(repo, u(ref), path, count))
|
147
147
|
add_headers(response, :content_type => "application/json", :ref => ref)
|
148
148
|
body(renderer.render(:tree_history, data, :layout => nil))
|
149
149
|
rescue Exception => err
|
@@ -151,7 +151,8 @@ module Dolt
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def resolve_repository(repo)
|
154
|
-
|
154
|
+
@cache ||= {}
|
155
|
+
@cache[repo] ||= actions.resolve_repository(repo)
|
155
156
|
end
|
156
157
|
|
157
158
|
private
|
@@ -38,6 +38,14 @@ describe Dolt::Sinatra::Actions do
|
|
38
38
|
assert_equal "blob:Blob", app.body
|
39
39
|
end
|
40
40
|
|
41
|
+
it "renders the blob template with custom data" do
|
42
|
+
renderer = Test::Renderer.new("Blob")
|
43
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), renderer)
|
44
|
+
app.blob("gitorious", "master", "app/models/repository.rb", { :who => 42 })
|
45
|
+
|
46
|
+
assert_equal 42, renderer.data[:who]
|
47
|
+
end
|
48
|
+
|
41
49
|
it "redirects tree views to tree action" do
|
42
50
|
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
43
51
|
app.blob("gitorious", "master", "app/models")
|
@@ -93,6 +101,14 @@ describe Dolt::Sinatra::Actions do
|
|
93
101
|
assert_equal "tree:Tree", app.body
|
94
102
|
end
|
95
103
|
|
104
|
+
it "renders template with custom data" do
|
105
|
+
renderer = Test::Renderer.new("Tree")
|
106
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), renderer)
|
107
|
+
app.tree("gitorious", "master", "app/models", { :who => 42 })
|
108
|
+
|
109
|
+
assert_equal 42, renderer.data[:who]
|
110
|
+
end
|
111
|
+
|
96
112
|
it "redirects blob views to blob action" do
|
97
113
|
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Tree"))
|
98
114
|
app.tree("gitorious", "master", "app/models/repository.rb")
|
@@ -150,6 +166,14 @@ describe Dolt::Sinatra::Actions do
|
|
150
166
|
assert_equal "tree:Tree", app.body
|
151
167
|
end
|
152
168
|
|
169
|
+
it "renders template with custom data" do
|
170
|
+
renderer = Test::Renderer.new("Tree")
|
171
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), renderer)
|
172
|
+
app.tree_entry("gitorious", "master", "app/models", { :who => 42 })
|
173
|
+
|
174
|
+
assert_equal 42, renderer.data[:who]
|
175
|
+
end
|
176
|
+
|
153
177
|
it "renders trees with the tree template as html" do
|
154
178
|
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
155
179
|
app.tree_entry("gitorious", "master", "app/models")
|
@@ -193,6 +217,14 @@ describe Dolt::Sinatra::Actions do
|
|
193
217
|
assert_equal "raw:Text", app.body
|
194
218
|
end
|
195
219
|
|
220
|
+
it "renders template with custom data" do
|
221
|
+
renderer = Test::Renderer.new("Text")
|
222
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), renderer)
|
223
|
+
app.raw("gitorious", "master", "app/models/repository.rb", { :who => 42 })
|
224
|
+
|
225
|
+
assert_equal 42, renderer.data[:who]
|
226
|
+
end
|
227
|
+
|
196
228
|
it "redirects tree views to tree action" do
|
197
229
|
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
198
230
|
app.raw("gitorious", "master", "app/models")
|
@@ -238,6 +270,14 @@ describe Dolt::Sinatra::Actions do
|
|
238
270
|
assert_equal "blame:Text", app.body
|
239
271
|
end
|
240
272
|
|
273
|
+
it "renders template with custom data" do
|
274
|
+
renderer = Test::Renderer.new("Text")
|
275
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), renderer)
|
276
|
+
app.blame("gitorious", "master", "app/models/repository.rb", { :who => 42 })
|
277
|
+
|
278
|
+
assert_equal 42, renderer.data[:who]
|
279
|
+
end
|
280
|
+
|
241
281
|
it "unescapes ref" do
|
242
282
|
actions = Test::Actions.new(Stub::Blob.new)
|
243
283
|
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
@@ -273,6 +313,14 @@ describe Dolt::Sinatra::Actions do
|
|
273
313
|
assert_equal "commits:Text", app.body
|
274
314
|
end
|
275
315
|
|
316
|
+
it "renders template with custom data" do
|
317
|
+
renderer = Test::Renderer.new("Text")
|
318
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), renderer)
|
319
|
+
app.history("gitorious", "master", "app/models/repository.rb", 10, { :who => 42 })
|
320
|
+
|
321
|
+
assert_equal 42, renderer.data[:who]
|
322
|
+
end
|
323
|
+
|
276
324
|
it "unescapes ref" do
|
277
325
|
actions = Test::Actions.new(Stub::Blob.new)
|
278
326
|
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
@@ -297,6 +345,14 @@ describe Dolt::Sinatra::Actions do
|
|
297
345
|
assert_equal "application/json", app.response["Content-Type"]
|
298
346
|
assert_equal "refs:JSON", app.body
|
299
347
|
end
|
348
|
+
|
349
|
+
it "renders template with custom data" do
|
350
|
+
renderer = Test::Renderer.new("Text")
|
351
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), renderer)
|
352
|
+
app.refs("gitorious", { :who => 42 })
|
353
|
+
|
354
|
+
assert_equal 42, renderer.data[:who]
|
355
|
+
end
|
300
356
|
end
|
301
357
|
|
302
358
|
describe "#tree_history" do
|
@@ -308,6 +364,14 @@ describe Dolt::Sinatra::Actions do
|
|
308
364
|
assert_equal "tree_history:JSON", app.body
|
309
365
|
end
|
310
366
|
|
367
|
+
it "renders template with custom data" do
|
368
|
+
renderer = Test::Renderer.new("Text")
|
369
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), renderer)
|
370
|
+
app.tree_history("gitorious", "master", "app/models", 1, { :who => 42 })
|
371
|
+
|
372
|
+
assert_equal 42, renderer.data[:who]
|
373
|
+
end
|
374
|
+
|
311
375
|
it "unescapes ref" do
|
312
376
|
actions = Test::Actions.new(Stub::Tree.new)
|
313
377
|
app = Test::SinatraApp.new(actions, Test::Renderer.new("Tree"))
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.20.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.19.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Christian Johansen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
15
|
+
name: libdolt
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0.21'
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
24
|
version_requirements: !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
@@ -26,15 +27,15 @@ dependencies:
|
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
28
29
|
version: '0.21'
|
29
|
-
name: libdolt
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
31
|
+
name: thin
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '1.4'
|
38
|
+
type: :runtime
|
38
39
|
prerelease: false
|
39
40
|
version_requirements: !ruby/object:Gem::Requirement
|
40
41
|
none: false
|
@@ -42,15 +43,15 @@ dependencies:
|
|
42
43
|
- - ~>
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: '1.4'
|
45
|
-
name: thin
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
47
|
+
name: sinatra
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.0'
|
54
|
+
type: :runtime
|
54
55
|
prerelease: false
|
55
56
|
version_requirements: !ruby/object:Gem::Requirement
|
56
57
|
none: false
|
@@ -58,15 +59,15 @@ dependencies:
|
|
58
59
|
- - ~>
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '1.0'
|
61
|
-
name: sinatra
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
63
|
+
name: tiltout
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.4'
|
70
|
+
type: :runtime
|
70
71
|
prerelease: false
|
71
72
|
version_requirements: !ruby/object:Gem::Requirement
|
72
73
|
none: false
|
@@ -74,15 +75,15 @@ dependencies:
|
|
74
75
|
- - ~>
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '1.4'
|
77
|
-
name: tiltout
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
79
|
+
name: json
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '1.5'
|
86
|
+
type: :runtime
|
86
87
|
prerelease: false
|
87
88
|
version_requirements: !ruby/object:Gem::Requirement
|
88
89
|
none: false
|
@@ -90,15 +91,15 @@ dependencies:
|
|
90
91
|
- - ~>
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '1.5'
|
93
|
-
name: json
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
|
95
|
+
name: trollop
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '2.0'
|
102
|
+
type: :runtime
|
102
103
|
prerelease: false
|
103
104
|
version_requirements: !ruby/object:Gem::Requirement
|
104
105
|
none: false
|
@@ -106,15 +107,15 @@ dependencies:
|
|
106
107
|
- - ~>
|
107
108
|
- !ruby/object:Gem::Version
|
108
109
|
version: '2.0'
|
109
|
-
name: trollop
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
|
111
|
+
name: minitest
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '2.0'
|
118
|
+
type: :development
|
118
119
|
prerelease: false
|
119
120
|
version_requirements: !ruby/object:Gem::Requirement
|
120
121
|
none: false
|
@@ -122,15 +123,15 @@ dependencies:
|
|
122
123
|
- - ~>
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '2.0'
|
125
|
-
name: minitest
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
|
127
|
+
name: rake
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0.9'
|
134
|
+
type: :development
|
134
135
|
prerelease: false
|
135
136
|
version_requirements: !ruby/object:Gem::Requirement
|
136
137
|
none: false
|
@@ -138,15 +139,15 @@ dependencies:
|
|
138
139
|
- - ~>
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0.9'
|
141
|
-
name: rake
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
|
-
|
143
|
+
name: rack-test
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
147
147
|
- - ~>
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0.6'
|
150
|
+
type: :development
|
150
151
|
prerelease: false
|
151
152
|
version_requirements: !ruby/object:Gem::Requirement
|
152
153
|
none: false
|
@@ -154,7 +155,6 @@ dependencies:
|
|
154
155
|
- - ~>
|
155
156
|
- !ruby/object:Gem::Version
|
156
157
|
version: '0.6'
|
157
|
-
name: rack-test
|
158
158
|
description: Dolt serves git trees and syntax highlighted blobs
|
159
159
|
email:
|
160
160
|
- christian@gitorious.org
|
@@ -247,8 +247,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
249
|
rubyforge_project: dolt
|
250
|
-
rubygems_version: 1.8.
|
250
|
+
rubygems_version: 1.8.25
|
251
251
|
signing_key:
|
252
252
|
specification_version: 3
|
253
253
|
summary: Dolt serves git trees and syntax highlighted blobs
|
254
254
|
test_files: []
|
255
|
+
has_rdoc:
|