dolt 0.20.0 → 0.21.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/dolt.gemspec +1 -1
- data/lib/dolt/sinatra/actions.rb +10 -24
- data/lib/dolt/sinatra/multi_repo_browser.rb +41 -13
- data/lib/dolt/sinatra/single_repo_browser.rb +41 -13
- data/test/dolt/sinatra/actions_test.rb +8 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dolt (0.
|
4
|
+
dolt (0.21.0)
|
5
5
|
json (~> 1.5)
|
6
6
|
libdolt (~> 0.21)
|
7
7
|
sinatra (~> 1.0)
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
eventmachine (1.0.3)
|
17
17
|
github-markup (0.7.5)
|
18
18
|
htmlentities (4.3.1)
|
19
|
-
json (1.
|
19
|
+
json (1.7.7)
|
20
20
|
libdolt (0.22.0)
|
21
21
|
htmlentities (~> 4.3)
|
22
22
|
json (~> 1.7)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
mime-types (1.23)
|
32
32
|
minitest (2.12.1)
|
33
33
|
posix-spawn (0.3.6)
|
34
|
-
pygments.rb (0.5.
|
34
|
+
pygments.rb (0.5.1)
|
35
35
|
posix-spawn (~> 0.3.6)
|
36
36
|
yajl-ruby (~> 1.1.0)
|
37
37
|
rack (1.5.2)
|
data/dolt.gemspec
CHANGED
data/lib/dolt/sinatra/actions.rb
CHANGED
@@ -22,8 +22,8 @@ require "cgi"
|
|
22
22
|
module Dolt
|
23
23
|
module Sinatra
|
24
24
|
module Actions
|
25
|
-
def redirect(url)
|
26
|
-
response.status =
|
25
|
+
def redirect(url, status = 302)
|
26
|
+
response.status = status
|
27
27
|
response["Location"] = url
|
28
28
|
body ""
|
29
29
|
end
|
@@ -55,7 +55,7 @@ module Dolt
|
|
55
55
|
|
56
56
|
def raw(repo, ref, path, custom_data = {})
|
57
57
|
if oid = lookup_ref_oid(repo, ref)
|
58
|
-
redirect(raw_url(repo, oid, path)) and return
|
58
|
+
redirect(raw_url(repo, oid, path), 307) and return
|
59
59
|
end
|
60
60
|
|
61
61
|
blob(repo, ref, path, custom_data, {
|
@@ -67,7 +67,7 @@ module Dolt
|
|
67
67
|
|
68
68
|
def blob(repo, ref, path, custom_data = {}, options = { :template => :blob })
|
69
69
|
if oid = lookup_ref_oid(repo, ref)
|
70
|
-
redirect(blob_url(repo, oid, path)) and return
|
70
|
+
redirect(blob_url(repo, oid, path), 307) and return
|
71
71
|
end
|
72
72
|
|
73
73
|
data = (custom_data || {}).merge(actions.blob(repo, u(ref), path))
|
@@ -76,13 +76,11 @@ module Dolt
|
|
76
76
|
add_headers(response, options.merge(:ref => ref))
|
77
77
|
tpl_options = options[:template_options] || {}
|
78
78
|
body(renderer.render(options[:template], data, tpl_options))
|
79
|
-
rescue Exception => err
|
80
|
-
error(err, repo, ref)
|
81
79
|
end
|
82
80
|
|
83
81
|
def tree(repo, ref, path, custom_data = {})
|
84
82
|
if oid = lookup_ref_oid(repo, ref)
|
85
|
-
redirect(tree_url(repo, oid, path)) and return
|
83
|
+
redirect(tree_url(repo, oid, path), 307) and return
|
86
84
|
end
|
87
85
|
|
88
86
|
data = (custom_data || {}).merge(actions.tree(repo, u(ref), path))
|
@@ -90,64 +88,52 @@ module Dolt
|
|
90
88
|
return redirect(blob_url(repo, ref, path)) if tree.class.to_s !~ /\bTree/
|
91
89
|
add_headers(response, :ref => ref)
|
92
90
|
body(renderer.render(:tree, data))
|
93
|
-
rescue Exception => err
|
94
|
-
error(err, repo, ref)
|
95
91
|
end
|
96
92
|
|
97
93
|
def tree_entry(repo, ref, path, custom_data = {})
|
98
94
|
if oid = lookup_ref_oid(repo, ref)
|
99
|
-
redirect(tree_entry_url(repo, oid, path)) and return
|
95
|
+
redirect(tree_entry_url(repo, oid, path), 307) and return
|
100
96
|
end
|
101
97
|
|
102
98
|
data = (custom_data || {}).merge(actions.tree_entry(repo, u(ref), path))
|
103
99
|
add_headers(response, :ref => ref)
|
104
100
|
body(renderer.render(data.key?(:tree) ? :tree : :blob, data))
|
105
|
-
rescue Exception => err
|
106
|
-
error(err, repo, ref)
|
107
101
|
end
|
108
102
|
|
109
103
|
def blame(repo, ref, path, custom_data = {})
|
110
104
|
if oid = lookup_ref_oid(repo, ref)
|
111
|
-
redirect(blame_url(repo, oid, path)) and return
|
105
|
+
redirect(blame_url(repo, oid, path), 307) and return
|
112
106
|
end
|
113
107
|
|
114
108
|
data = (custom_data || {}).merge(actions.blame(repo, u(ref), path))
|
115
109
|
add_headers(response, :ref => ref)
|
116
110
|
body(renderer.render(:blame, data))
|
117
|
-
rescue Exception => err
|
118
|
-
error(err, repo, ref)
|
119
111
|
end
|
120
112
|
|
121
113
|
def history(repo, ref, path, count, custom_data = {})
|
122
114
|
if oid = lookup_ref_oid(repo, ref)
|
123
|
-
redirect(history_url(repo, oid, path)) and return
|
115
|
+
redirect(history_url(repo, oid, path), 307) and return
|
124
116
|
end
|
125
117
|
|
126
118
|
data = (custom_data || {}).merge(actions.history(repo, u(ref), path, count))
|
127
119
|
add_headers(response, :ref => ref)
|
128
120
|
body(renderer.render(:commits, data))
|
129
|
-
rescue Exception => err
|
130
|
-
error(err, repo, ref)
|
131
121
|
end
|
132
122
|
|
133
123
|
def refs(repo, custom_data = {})
|
134
124
|
data = (custom_data || {}).merge(actions.refs(repo))
|
135
125
|
add_headers(response, :content_type => "application/json")
|
136
126
|
body(renderer.render(:refs, data, :layout => nil))
|
137
|
-
rescue Exception => err
|
138
|
-
error(err, repo, nil)
|
139
127
|
end
|
140
128
|
|
141
129
|
def tree_history(repo, ref, path, count = 1, custom_data = {})
|
142
130
|
if oid = lookup_ref_oid(repo, ref)
|
143
|
-
redirect(tree_history_url(repo, oid, path)) and return
|
131
|
+
redirect(tree_history_url(repo, oid, path), 307) and return
|
144
132
|
end
|
145
133
|
|
146
134
|
data = (custom_data || {}).merge(actions.tree_history(repo, u(ref), path, count))
|
147
135
|
add_headers(response, :content_type => "application/json", :ref => ref)
|
148
136
|
body(renderer.render(:tree_history, data, :layout => nil))
|
149
|
-
rescue Exception => err
|
150
|
-
error(err, repo, ref)
|
151
137
|
end
|
152
138
|
|
153
139
|
def resolve_repository(repo)
|
@@ -155,12 +141,12 @@ module Dolt
|
|
155
141
|
@cache[repo] ||= actions.resolve_repository(repo)
|
156
142
|
end
|
157
143
|
|
158
|
-
private
|
159
144
|
def lookup_ref_oid(repo, ref)
|
160
145
|
return if !respond_to?(:redirect_refs?) || !redirect_refs? || ref.length == 40
|
161
146
|
actions.rev_parse_oid(repo, ref)
|
162
147
|
end
|
163
148
|
|
149
|
+
private
|
164
150
|
def u(str)
|
165
151
|
# Temporarily swap the + out with a magic byte, so
|
166
152
|
# filenames/branches with +'s won't get unescaped to a space
|
@@ -39,8 +39,12 @@ module Dolt
|
|
39
39
|
end
|
40
40
|
|
41
41
|
get "/*/tree/*:*" do
|
42
|
-
|
43
|
-
|
42
|
+
begin
|
43
|
+
repo, ref, path = params[:splat]
|
44
|
+
tree(repo, ref, path)
|
45
|
+
rescue Exception => err
|
46
|
+
error(err, repo, ref)
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
get "/*/tree/*" do
|
@@ -48,8 +52,12 @@ module Dolt
|
|
48
52
|
end
|
49
53
|
|
50
54
|
get "/*/blob/*:*" do
|
51
|
-
|
52
|
-
|
55
|
+
begin
|
56
|
+
repo, ref, path = params[:splat]
|
57
|
+
blob(repo, ref, path)
|
58
|
+
rescue Exception => err
|
59
|
+
error(err, repo, ref)
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
get "/*/blob/*" do
|
@@ -57,8 +65,12 @@ module Dolt
|
|
57
65
|
end
|
58
66
|
|
59
67
|
get "/*/raw/*:*" do
|
60
|
-
|
61
|
-
|
68
|
+
begin
|
69
|
+
repo, ref, path = params[:splat]
|
70
|
+
raw(repo, ref, path)
|
71
|
+
rescue Exception => err
|
72
|
+
error(err, repo, ref)
|
73
|
+
end
|
62
74
|
end
|
63
75
|
|
64
76
|
get "/*/raw/*" do
|
@@ -66,8 +78,12 @@ module Dolt
|
|
66
78
|
end
|
67
79
|
|
68
80
|
get "/*/blame/*:*" do
|
69
|
-
|
70
|
-
|
81
|
+
begin
|
82
|
+
repo, ref, path = params[:splat]
|
83
|
+
blame(repo, ref, path)
|
84
|
+
rescue Exception => err
|
85
|
+
error(err, repo, ref)
|
86
|
+
end
|
71
87
|
end
|
72
88
|
|
73
89
|
get "/*/blame/*" do
|
@@ -75,8 +91,12 @@ module Dolt
|
|
75
91
|
end
|
76
92
|
|
77
93
|
get "/*/history/*:*" do
|
78
|
-
|
79
|
-
|
94
|
+
begin
|
95
|
+
repo, ref, path = params[:splat]
|
96
|
+
history(repo, ref, path, (params[:commit_count] || 20).to_i)
|
97
|
+
rescue Exception => err
|
98
|
+
error(err, repo, ref)
|
99
|
+
end
|
80
100
|
end
|
81
101
|
|
82
102
|
get "/*/history/*" do
|
@@ -84,12 +104,20 @@ module Dolt
|
|
84
104
|
end
|
85
105
|
|
86
106
|
get "/*/refs" do
|
87
|
-
|
107
|
+
begin
|
108
|
+
refs(params[:splat].first)
|
109
|
+
rescue Exception => err
|
110
|
+
error(err, repo, nil)
|
111
|
+
end
|
88
112
|
end
|
89
113
|
|
90
114
|
get "/*/tree_history/*:*" do
|
91
|
-
|
92
|
-
|
115
|
+
begin
|
116
|
+
repo, ref, path = params[:splat]
|
117
|
+
tree_history(repo, ref, path)
|
118
|
+
rescue Exception => err
|
119
|
+
error(err, repo, ref)
|
120
|
+
end
|
93
121
|
end
|
94
122
|
|
95
123
|
private
|
@@ -40,8 +40,12 @@ module Dolt
|
|
40
40
|
end
|
41
41
|
|
42
42
|
get "/tree/*:*" do
|
43
|
-
|
44
|
-
|
43
|
+
begin
|
44
|
+
ref, path = params[:splat]
|
45
|
+
tree(repo, ref, path)
|
46
|
+
rescue Exception => err
|
47
|
+
error(err, repo, ref)
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
get "/tree/*" do
|
@@ -49,8 +53,12 @@ module Dolt
|
|
49
53
|
end
|
50
54
|
|
51
55
|
get "/blob/*:*" do
|
52
|
-
|
53
|
-
|
56
|
+
begin
|
57
|
+
ref, path = params[:splat]
|
58
|
+
blob(repo, ref, path)
|
59
|
+
rescue Exception => err
|
60
|
+
error(err, repo, ref)
|
61
|
+
end
|
54
62
|
end
|
55
63
|
|
56
64
|
get "/blob/*" do
|
@@ -58,8 +66,12 @@ module Dolt
|
|
58
66
|
end
|
59
67
|
|
60
68
|
get "/raw/*:*" do
|
61
|
-
|
62
|
-
|
69
|
+
begin
|
70
|
+
ref, path = params[:splat]
|
71
|
+
raw(repo, ref, path)
|
72
|
+
rescue Exception => err
|
73
|
+
error(err, repo, ref)
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
77
|
get "/raw/*" do
|
@@ -67,8 +79,12 @@ module Dolt
|
|
67
79
|
end
|
68
80
|
|
69
81
|
get "/blame/*:*" do
|
70
|
-
|
71
|
-
|
82
|
+
begin
|
83
|
+
ref, path = params[:splat]
|
84
|
+
blame(repo, ref, path)
|
85
|
+
rescue Exception => err
|
86
|
+
error(err, repo, ref)
|
87
|
+
end
|
72
88
|
end
|
73
89
|
|
74
90
|
get "/blame/*" do
|
@@ -76,8 +92,12 @@ module Dolt
|
|
76
92
|
end
|
77
93
|
|
78
94
|
get "/history/*:*" do
|
79
|
-
|
80
|
-
|
95
|
+
begin
|
96
|
+
ref, path = params[:splat]
|
97
|
+
history(repo, ref, path, (params[:commit_count] || 20).to_i)
|
98
|
+
rescue Exception => err
|
99
|
+
error(err, repo, ref)
|
100
|
+
end
|
81
101
|
end
|
82
102
|
|
83
103
|
get "/history/*" do
|
@@ -85,12 +105,20 @@ module Dolt
|
|
85
105
|
end
|
86
106
|
|
87
107
|
get "/refs" do
|
88
|
-
|
108
|
+
begin
|
109
|
+
refs(repo)
|
110
|
+
rescue Exception => err
|
111
|
+
error(err, repo, ref)
|
112
|
+
end
|
89
113
|
end
|
90
114
|
|
91
115
|
get "/tree_history/*:*" do
|
92
|
-
|
93
|
-
|
116
|
+
begin
|
117
|
+
ref, path = params[:splat]
|
118
|
+
tree_history(repo, ref, path)
|
119
|
+
rescue Exception => err
|
120
|
+
error(err, repo, ref)
|
121
|
+
end
|
94
122
|
end
|
95
123
|
|
96
124
|
private
|
@@ -69,6 +69,7 @@ describe Dolt::Sinatra::Actions do
|
|
69
69
|
|
70
70
|
location = app.response["Location"]
|
71
71
|
refute_equal 302, app.response.status
|
72
|
+
refute_equal 307, app.response.status
|
72
73
|
end
|
73
74
|
|
74
75
|
it "redirects ref to oid if configured so" do
|
@@ -76,7 +77,7 @@ describe Dolt::Sinatra::Actions do
|
|
76
77
|
app.blob("gitorious", "master", "lib/gitorious.rb")
|
77
78
|
|
78
79
|
location = app.response["Location"]
|
79
|
-
assert_equal
|
80
|
+
assert_equal 307, app.response.status
|
80
81
|
assert_equal "/gitorious/blob/#{'a' * 40}:lib/gitorious.rb", location
|
81
82
|
assert_equal "", app.body
|
82
83
|
end
|
@@ -153,6 +154,7 @@ describe Dolt::Sinatra::Actions do
|
|
153
154
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
154
155
|
app.tree("gitorious", "master", "lib")
|
155
156
|
|
157
|
+
assert_equal 307, app.response.status
|
156
158
|
assert_equal "/gitorious/tree/#{'a' * 40}:lib", app.response["Location"]
|
157
159
|
end
|
158
160
|
end
|
@@ -194,6 +196,7 @@ describe Dolt::Sinatra::Actions do
|
|
194
196
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
195
197
|
app.tree_entry("gitorious", "master", "lib")
|
196
198
|
|
199
|
+
assert_equal 307, app.response.status
|
197
200
|
assert_equal "/gitorious/source/#{'a' * 40}:lib", app.response["Location"]
|
198
201
|
end
|
199
202
|
end
|
@@ -247,6 +250,7 @@ describe Dolt::Sinatra::Actions do
|
|
247
250
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
248
251
|
app.raw("gitorious", "master", "lib/gitorious.rb")
|
249
252
|
|
253
|
+
assert_equal 307, app.response.status
|
250
254
|
assert_equal "/gitorious/raw/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
251
255
|
end
|
252
256
|
end
|
@@ -290,6 +294,7 @@ describe Dolt::Sinatra::Actions do
|
|
290
294
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
291
295
|
app.blame("gitorious", "master", "lib/gitorious.rb")
|
292
296
|
|
297
|
+
assert_equal 307, app.response.status
|
293
298
|
assert_equal "/gitorious/blame/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
294
299
|
end
|
295
300
|
end
|
@@ -333,6 +338,7 @@ describe Dolt::Sinatra::Actions do
|
|
333
338
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
334
339
|
app.history("gitorious", "master", "lib/gitorious.rb", 10)
|
335
340
|
|
341
|
+
assert_equal 307, app.response.status
|
336
342
|
assert_equal "/gitorious/history/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
337
343
|
end
|
338
344
|
end
|
@@ -384,6 +390,7 @@ describe Dolt::Sinatra::Actions do
|
|
384
390
|
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
385
391
|
app.tree_history("gitorious", "master", "lib", 10)
|
386
392
|
|
393
|
+
assert_equal 307, app.response.status
|
387
394
|
assert_equal "/gitorious/tree_history/#{'a' * 40}:lib", app.response["Location"]
|
388
395
|
end
|
389
396
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libdolt
|