dolt 0.11.0 → 0.12.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 +21 -34
- data/dolt.gemspec +3 -4
- data/lib/dolt/sinatra/actions.rb +43 -59
- data/lib/dolt/sinatra/base.rb +1 -3
- data/lib/dolt/sinatra/multi_repo_browser.rb +13 -13
- data/lib/dolt/sinatra/single_repo_browser.rb +13 -13
- data/test/dolt/sinatra/actions_test.rb +48 -179
- data/test/dolt/sinatra/multi_repo_browser_test.rb +41 -0
- data/test/dolt/sinatra/single_repo_browser_test.rb +42 -0
- data/test/test_helper.rb +145 -11
- metadata +12 -26
data/Gemfile.lock
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dolt (0.
|
5
|
-
async_sinatra (~> 1.0)
|
4
|
+
dolt (0.12.0)
|
6
5
|
json (~> 1.5)
|
7
|
-
libdolt (~> 0.
|
6
|
+
libdolt (~> 0.17)
|
8
7
|
sinatra (~> 1.0)
|
9
8
|
thin (~> 1.4)
|
10
9
|
tiltout (~> 1.4)
|
@@ -12,59 +11,47 @@ PATH
|
|
12
11
|
GEM
|
13
12
|
remote: http://rubygems.org/
|
14
13
|
specs:
|
15
|
-
async_sinatra (1.0.0)
|
16
|
-
rack (>= 1.4.1)
|
17
|
-
sinatra (>= 1.3.2)
|
18
14
|
daemons (1.1.9)
|
19
|
-
|
20
|
-
eventmachine
|
21
|
-
em_pessimistic (0.1.2)
|
22
|
-
eventmachine (~> 1.0)
|
23
|
-
em_rugged (0.3.0)
|
24
|
-
eventmachine (~> 1.0)
|
25
|
-
rugged (= 0.17.0.b6)
|
26
|
-
eventmachine (1.0.0)
|
15
|
+
eventmachine (1.0.3)
|
27
16
|
github-markup (0.7.5)
|
28
17
|
htmlentities (4.3.1)
|
29
|
-
json (1.
|
30
|
-
libdolt (0.
|
31
|
-
em_pessimistic (~> 0.1)
|
32
|
-
em_rugged (~> 0.3)
|
33
|
-
eventmachine (~> 1.0)
|
18
|
+
json (1.8.0)
|
19
|
+
libdolt (0.17.0)
|
34
20
|
htmlentities (~> 4.3)
|
35
21
|
json (~> 1.7)
|
36
22
|
makeup (~> 0.2)
|
37
23
|
mime-types (~> 1.19)
|
24
|
+
rugged (= 0.17.0.b6)
|
38
25
|
tzinfo (~> 0.3)
|
39
|
-
when (~> 0)
|
40
26
|
makeup (0.3.0)
|
41
27
|
github-markup (~> 0.7)
|
42
28
|
htmlentities (~> 4.3)
|
43
29
|
pygments.rb (~> 0.2)
|
44
|
-
mime-types (1.
|
30
|
+
mime-types (1.23)
|
45
31
|
minitest (2.12.1)
|
46
32
|
posix-spawn (0.3.6)
|
47
|
-
pygments.rb (0.
|
33
|
+
pygments.rb (0.5.0)
|
48
34
|
posix-spawn (~> 0.3.6)
|
49
35
|
yajl-ruby (~> 1.1.0)
|
50
|
-
rack (1.
|
51
|
-
rack-protection (1.
|
36
|
+
rack (1.5.2)
|
37
|
+
rack-protection (1.5.0)
|
52
38
|
rack
|
53
|
-
|
39
|
+
rack-test (0.6.2)
|
40
|
+
rack (>= 1.0)
|
41
|
+
rake (0.9.6)
|
54
42
|
rugged (0.17.0.b6)
|
55
|
-
sinatra (1.
|
56
|
-
rack (~> 1.
|
57
|
-
rack-protection (~> 1.
|
58
|
-
tilt (~> 1.3, >= 1.3.
|
59
|
-
thin (1.5.
|
43
|
+
sinatra (1.4.2)
|
44
|
+
rack (~> 1.5, >= 1.5.2)
|
45
|
+
rack-protection (~> 1.4)
|
46
|
+
tilt (~> 1.3, >= 1.3.4)
|
47
|
+
thin (1.5.1)
|
60
48
|
daemons (>= 1.0.9)
|
61
49
|
eventmachine (>= 0.12.6)
|
62
50
|
rack (>= 1.0.0)
|
63
|
-
tilt (1.
|
51
|
+
tilt (1.4.1)
|
64
52
|
tiltout (1.4.0)
|
65
53
|
tilt (~> 1.3)
|
66
|
-
tzinfo (0.3.
|
67
|
-
when (0.1.0)
|
54
|
+
tzinfo (0.3.37)
|
68
55
|
yajl-ruby (1.1.0)
|
69
56
|
|
70
57
|
PLATFORMS
|
@@ -72,6 +59,6 @@ PLATFORMS
|
|
72
59
|
|
73
60
|
DEPENDENCIES
|
74
61
|
dolt!
|
75
|
-
em-minitest-spec (~> 1.1)
|
76
62
|
minitest (~> 2.0)
|
63
|
+
rack-test (~> 0.6)
|
77
64
|
rake (~> 0.9)
|
data/dolt.gemspec
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
Gem::Specification.new do |s|
|
13
13
|
s.name = "dolt"
|
14
|
-
s.version = "0.
|
14
|
+
s.version = "0.12.0"
|
15
15
|
s.authors = ["Christian Johansen"]
|
16
16
|
s.email = ["christian@gitorious.org"]
|
17
17
|
s.homepage = "http://gitorious.org/gitorious/dolt"
|
@@ -20,16 +20,15 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.rubyforge_project = "dolt"
|
22
22
|
|
23
|
-
s.add_dependency "libdolt", "~>0.
|
23
|
+
s.add_dependency "libdolt", "~>0.17"
|
24
24
|
s.add_dependency "thin", "~>1.4"
|
25
25
|
s.add_dependency "sinatra", "~>1.0"
|
26
|
-
s.add_dependency "async_sinatra", "~>1.0"
|
27
26
|
s.add_dependency "tiltout", "~>1.4"
|
28
27
|
s.add_dependency "json", "~>1.5"
|
29
28
|
|
30
29
|
s.add_development_dependency "minitest", "~> 2.0"
|
31
|
-
s.add_development_dependency "em-minitest-spec", "~> 1.1"
|
32
30
|
s.add_development_dependency "rake", "~> 0.9"
|
31
|
+
s.add_development_dependency "rack-test", "~> 0.6"
|
33
32
|
|
34
33
|
s.files = GemSpecHelper.files(".") + GemSpecHelper.files("vendor/ui")
|
35
34
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
data/lib/dolt/sinatra/actions.rb
CHANGED
@@ -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
|
@@ -21,8 +21,6 @@ require "time"
|
|
21
21
|
module Dolt
|
22
22
|
module Sinatra
|
23
23
|
module Actions
|
24
|
-
# Built-in redirect seems to not work with Sinatra::Async, it throws
|
25
|
-
# an error.
|
26
24
|
def redirect(url)
|
27
25
|
response.status = 302
|
28
26
|
response["Location"] = url
|
@@ -30,8 +28,9 @@ module Dolt
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def error(error, repo, ref)
|
31
|
+
template = error.class.to_s == "Rugged::IndexerError" ? :"404" : :"500"
|
33
32
|
add_headers(response)
|
34
|
-
body(renderer.render(
|
33
|
+
body(renderer.render(template, {
|
35
34
|
:error => error,
|
36
35
|
:repository_slug => repo,
|
37
36
|
:ref => ref
|
@@ -70,14 +69,14 @@ module Dolt
|
|
70
69
|
redirect(blob_url(repo, oid, path)) and return
|
71
70
|
end
|
72
71
|
|
73
|
-
actions.blob(repo, u(ref), path)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
72
|
+
data = actions.blob(repo, u(ref), path)
|
73
|
+
blob = data[:blob]
|
74
|
+
return redirect(tree_url(repo, ref, path)) if blob.class.to_s !~ /\bBlob/
|
75
|
+
add_headers(response, options.merge(:ref => ref))
|
76
|
+
tpl_options = options[:template_options] || {}
|
77
|
+
body(renderer.render(options[:template], data, tpl_options))
|
78
|
+
rescue Exception => err
|
79
|
+
error(err, repo, ref)
|
81
80
|
end
|
82
81
|
|
83
82
|
def tree(repo, ref, path)
|
@@ -85,17 +84,13 @@ module Dolt
|
|
85
84
|
redirect(tree_url(repo, oid, path)) and return
|
86
85
|
end
|
87
86
|
|
88
|
-
actions.tree(repo, u(ref), path)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rescue Exception => err
|
96
|
-
error(err, repo, ref)
|
97
|
-
end
|
98
|
-
end
|
87
|
+
data = actions.tree(repo, u(ref), path)
|
88
|
+
tree = data[:tree]
|
89
|
+
return redirect(blob_url(repo, ref, path)) if tree.class.to_s !~ /\bTree/
|
90
|
+
add_headers(response, :ref => ref)
|
91
|
+
body(renderer.render(:tree, data))
|
92
|
+
rescue Exception => err
|
93
|
+
error(err, repo, ref)
|
99
94
|
end
|
100
95
|
|
101
96
|
def tree_entry(repo, ref, path)
|
@@ -103,15 +98,11 @@ module Dolt
|
|
103
98
|
redirect(tree_entry_url(repo, oid, path)) and return
|
104
99
|
end
|
105
100
|
|
106
|
-
actions.tree_entry(repo, u(ref), path)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
rescue Exception => err
|
112
|
-
error(err, repo, ref)
|
113
|
-
end
|
114
|
-
end
|
101
|
+
data = actions.tree_entry(repo, u(ref), path)
|
102
|
+
add_headers(response, :ref => ref)
|
103
|
+
body(renderer.render(data.key?(:tree) ? :tree : :blob, data))
|
104
|
+
rescue Exception => err
|
105
|
+
error(err, repo, ref)
|
115
106
|
end
|
116
107
|
|
117
108
|
def blame(repo, ref, path)
|
@@ -119,11 +110,11 @@ module Dolt
|
|
119
110
|
redirect(blame_url(repo, oid, path)) and return
|
120
111
|
end
|
121
112
|
|
122
|
-
actions.blame(repo, u(ref), path)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
113
|
+
data = actions.blame(repo, u(ref), path)
|
114
|
+
add_headers(response, :ref => ref)
|
115
|
+
body(renderer.render(:blame, data))
|
116
|
+
rescue Exception => err
|
117
|
+
error(err, repo, ref)
|
127
118
|
end
|
128
119
|
|
129
120
|
def history(repo, ref, path, count)
|
@@ -131,19 +122,19 @@ module Dolt
|
|
131
122
|
redirect(history_url(repo, oid, path)) and return
|
132
123
|
end
|
133
124
|
|
134
|
-
actions.history(repo, u(ref), path, count)
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
125
|
+
data = actions.history(repo, u(ref), path, count)
|
126
|
+
add_headers(response, :ref => ref)
|
127
|
+
body(renderer.render(:commits, data))
|
128
|
+
rescue Exception => err
|
129
|
+
error(err, repo, ref)
|
139
130
|
end
|
140
131
|
|
141
132
|
def refs(repo)
|
142
|
-
actions.refs(repo)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
133
|
+
data = actions.refs(repo)
|
134
|
+
add_headers(response, :content_type => "application/json")
|
135
|
+
body(renderer.render(:refs, data, :layout => nil))
|
136
|
+
rescue Exception => err
|
137
|
+
error(err, repo, nil)
|
147
138
|
end
|
148
139
|
|
149
140
|
def tree_history(repo, ref, path, count = 1)
|
@@ -151,18 +142,11 @@ module Dolt
|
|
151
142
|
redirect(tree_history_url(repo, oid, path)) and return
|
152
143
|
end
|
153
144
|
|
154
|
-
actions.tree_history(repo, u(ref), path, count)
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
add_headers(response, :content_type => "application/json", :ref => ref)
|
160
|
-
body(renderer.render(:tree_history, data, :layout => nil))
|
161
|
-
end
|
162
|
-
rescue Exception => err
|
163
|
-
error(err, repo, ref)
|
164
|
-
end
|
165
|
-
end
|
145
|
+
data = actions.tree_history(repo, u(ref), path, count)
|
146
|
+
add_headers(response, :content_type => "application/json", :ref => ref)
|
147
|
+
body(renderer.render(:tree_history, data, :layout => nil))
|
148
|
+
rescue Exception => err
|
149
|
+
error(err, repo, ref)
|
166
150
|
end
|
167
151
|
|
168
152
|
def resolve_repository(repo)
|
data/lib/dolt/sinatra/base.rb
CHANGED
@@ -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
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
#++
|
18
18
|
require "sinatra/base"
|
19
|
-
require "sinatra/async"
|
20
19
|
require "dolt/sinatra/actions"
|
21
20
|
|
22
21
|
module Dolt
|
@@ -24,7 +23,6 @@ module Dolt
|
|
24
23
|
class Base < ::Sinatra::Base
|
25
24
|
attr_reader :actions, :renderer
|
26
25
|
include Dolt::Sinatra::Actions
|
27
|
-
register ::Sinatra::Async
|
28
26
|
|
29
27
|
def initialize(actions, renderer)
|
30
28
|
@actions = actions
|
@@ -27,61 +27,61 @@ module Dolt
|
|
27
27
|
include Dolt::View::Blob
|
28
28
|
include Dolt::View::Tree
|
29
29
|
|
30
|
-
|
30
|
+
get "/" do
|
31
31
|
response["Content-Type"] = "text/html"
|
32
32
|
body(renderer.render(:index, { :repositories => actions.repositories }))
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
get "/*/tree/*:*" do
|
36
36
|
repo, ref, path = params[:splat]
|
37
37
|
tree(repo, ref, path)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
get "/*/tree/*" do
|
41
41
|
force_ref(params[:splat], "tree", "master")
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
get "/*/blob/*:*" do
|
45
45
|
repo, ref, path = params[:splat]
|
46
46
|
blob(repo, ref, path)
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
get "/*/blob/*" do
|
50
50
|
force_ref(params[:splat], "blob", "master")
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
get "/*/raw/*:*" do
|
54
54
|
repo, ref, path = params[:splat]
|
55
55
|
raw(repo, ref, path)
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
get "/*/raw/*" do
|
59
59
|
force_ref(params[:splat], "raw", "master")
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
get "/*/blame/*:*" do
|
63
63
|
repo, ref, path = params[:splat]
|
64
64
|
blame(repo, ref, path)
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
get "/*/blame/*" do
|
68
68
|
force_ref(params[:splat], "blame", "master")
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
get "/*/history/*:*" do
|
72
72
|
repo, ref, path = params[:splat]
|
73
73
|
history(repo, ref, path, (params[:commit_count] || 20).to_i)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
get "/*/history/*" do
|
77
77
|
force_ref(params[:splat], "history", "master")
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
get "/*/refs" do
|
81
81
|
refs(params[:splat].first)
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
get "/*/tree_history/*:*" do
|
85
85
|
repo, ref, path = params[:splat]
|
86
86
|
tree_history(repo, ref, path)
|
87
87
|
end
|
@@ -33,60 +33,60 @@ module Dolt
|
|
33
33
|
super(actions, renderer)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
get "/" do
|
37
37
|
redirect("/tree/master:")
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
get "/tree/*:*" do
|
41
41
|
ref, path = params[:splat]
|
42
42
|
tree(repo, ref, path)
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
get "/tree/*" do
|
46
46
|
force_ref(params[:splat], "tree", "master")
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
get "/blob/*:*" do
|
50
50
|
ref, path = params[:splat]
|
51
51
|
blob(repo, ref, path)
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
get "/blob/*" do
|
55
55
|
force_ref(params[:splat], "blob", "master")
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
get "/raw/*:*" do
|
59
59
|
ref, path = params[:splat]
|
60
60
|
raw(repo, ref, path)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
get "/raw/*" do
|
64
64
|
force_ref(params[:splat], "raw", "master")
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
get "/blame/*:*" do
|
68
68
|
ref, path = params[:splat]
|
69
69
|
blame(repo, ref, path)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
get "/blame/*" do
|
73
73
|
force_ref(params[:splat], "blame", "master")
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
get "/history/*:*" do
|
77
77
|
ref, path = params[:splat]
|
78
78
|
history(repo, ref, path, (params[:commit_count] || 20).to_i)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
81
|
+
get "/history/*" do
|
82
82
|
force_ref(params[:splat], "blame", "master")
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
get "/refs" do
|
86
86
|
refs(repo)
|
87
87
|
end
|
88
88
|
|
89
|
-
|
89
|
+
get "/tree_history/*:*" do
|
90
90
|
ref, path = params[:splat]
|
91
91
|
tree_history(repo, ref, path)
|
92
92
|
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
|
@@ -18,142 +18,11 @@
|
|
18
18
|
require "test_helper"
|
19
19
|
require "dolt/sinatra/actions"
|
20
20
|
|
21
|
-
class DummySinatraApp
|
22
|
-
include Dolt::Sinatra::Actions
|
23
|
-
attr_reader :actions, :renderer
|
24
|
-
|
25
|
-
def initialize(actions, renderer)
|
26
|
-
@actions = actions
|
27
|
-
@renderer = renderer
|
28
|
-
end
|
29
|
-
|
30
|
-
def body(str = nil)
|
31
|
-
@body = str if !str.nil?
|
32
|
-
@body
|
33
|
-
end
|
34
|
-
|
35
|
-
def response
|
36
|
-
if !@response
|
37
|
-
@response = {}
|
38
|
-
def @response.status; @status; end
|
39
|
-
def @response.status=(status); @status = status; end
|
40
|
-
end
|
41
|
-
@response
|
42
|
-
end
|
43
|
-
|
44
|
-
def tree_url(repo, ref, path)
|
45
|
-
"/#{repo}/tree/#{ref}:#{path}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def blob_url(repo, ref, path)
|
49
|
-
"/#{repo}/blob/#{ref}:#{path}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def tree_entry_url(repo, ref, path)
|
53
|
-
"/#{repo}/source/#{ref}:#{path}"
|
54
|
-
end
|
55
|
-
|
56
|
-
def blame_url(repo, ref, path)
|
57
|
-
"/#{repo}/blame/#{ref}:#{path}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def history_url(repo, ref, path)
|
61
|
-
"/#{repo}/history/#{ref}:#{path}"
|
62
|
-
end
|
63
|
-
|
64
|
-
def tree_history_url(repo, ref, path)
|
65
|
-
"/#{repo}/tree_history/#{ref}:#{path}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def raw_url(repo, ref, path)
|
69
|
-
"/#{repo}/raw/#{ref}:#{path}"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class RedirectingDummySinatraApp < DummySinatraApp
|
74
|
-
def redirect_refs?; true; end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Renderer
|
78
|
-
def initialize(body = ""); @body = body; end
|
79
|
-
|
80
|
-
def render(action, data, options = {})
|
81
|
-
@action = action
|
82
|
-
@data = data
|
83
|
-
"#{action}:#@body"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class BlobStub
|
88
|
-
def is_a?(type)
|
89
|
-
type == Rugged::Blob
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
class TreeStub
|
94
|
-
def is_a?(type)
|
95
|
-
type == Rugged::Tree
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class Actions
|
100
|
-
attr_reader :repo, :ref, :path
|
101
|
-
|
102
|
-
def initialize(response)
|
103
|
-
@response = response
|
104
|
-
end
|
105
|
-
|
106
|
-
def blob(repo, ref, path, &block)
|
107
|
-
respond(:blob, repo, ref, path, &block)
|
108
|
-
end
|
109
|
-
|
110
|
-
def tree(repo, ref, path, &block)
|
111
|
-
respond(:tree, repo, ref, path, &block)
|
112
|
-
end
|
113
|
-
|
114
|
-
def tree_entry(repo, ref, path, &block)
|
115
|
-
respond(:tree_entry, repo, ref, path, &block)
|
116
|
-
end
|
117
|
-
|
118
|
-
def raw(repo, ref, path, &block)
|
119
|
-
respond(:raw, repo, ref, path, &block)
|
120
|
-
end
|
121
|
-
|
122
|
-
def blame(repo, ref, path, &block)
|
123
|
-
respond(:blame, repo, ref, path, &block)
|
124
|
-
end
|
125
|
-
|
126
|
-
def history(repo, ref, path, limit, &block)
|
127
|
-
respond(:history, repo, ref, path, &block)
|
128
|
-
end
|
129
|
-
|
130
|
-
def refs(repo, &block)
|
131
|
-
respond(:refs, repo, nil, nil, &block)
|
132
|
-
end
|
133
|
-
|
134
|
-
def tree_history(repo, ref, path, count, &block)
|
135
|
-
respond(:tree_history, repo, ref, path, &block)
|
136
|
-
end
|
137
|
-
|
138
|
-
def respond(type, repo, ref, path, &block)
|
139
|
-
@repo = repo
|
140
|
-
@ref = ref
|
141
|
-
@path = path
|
142
|
-
data = { :ref => ref, :repository => repo }
|
143
|
-
data[type != :tree_entry ? type : (@response.class.to_s =~ /Tree/ ? :tree : :blob)] = @response
|
144
|
-
block.call(nil, data)
|
145
|
-
end
|
146
|
-
|
147
|
-
def rev_parse_oid(repo, ref)
|
148
|
-
"a" * 40
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
21
|
describe Dolt::Sinatra::Actions do
|
153
22
|
describe "#blob" do
|
154
23
|
it "delegates to actions" do
|
155
|
-
actions = Actions.new(
|
156
|
-
app =
|
24
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
25
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new)
|
157
26
|
app.blob("gitorious", "master", "app/models/repository.rb")
|
158
27
|
|
159
28
|
assert_equal "gitorious", actions.repo
|
@@ -162,7 +31,7 @@ describe Dolt::Sinatra::Actions do
|
|
162
31
|
end
|
163
32
|
|
164
33
|
it "renders the blob template as html" do
|
165
|
-
app =
|
34
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
166
35
|
app.blob("gitorious", "master", "app/models/repository.rb")
|
167
36
|
|
168
37
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -170,7 +39,7 @@ describe Dolt::Sinatra::Actions do
|
|
170
39
|
end
|
171
40
|
|
172
41
|
it "redirects tree views to tree action" do
|
173
|
-
app =
|
42
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
174
43
|
app.blob("gitorious", "master", "app/models")
|
175
44
|
|
176
45
|
assert_equal 302, app.response.status
|
@@ -179,15 +48,15 @@ describe Dolt::Sinatra::Actions do
|
|
179
48
|
end
|
180
49
|
|
181
50
|
it "unescapes ref" do
|
182
|
-
actions = Actions.new(
|
183
|
-
app =
|
51
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
52
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
184
53
|
app.blob("gitorious", "issue-%23221", "app/my documents")
|
185
54
|
|
186
55
|
assert_equal "issue-#221", actions.ref
|
187
56
|
end
|
188
57
|
|
189
58
|
it "does not redirect ref to oid by default" do
|
190
|
-
app =
|
59
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
191
60
|
app.blob("gitorious", "master", "lib/gitorious.rb")
|
192
61
|
|
193
62
|
location = app.response["Location"]
|
@@ -195,7 +64,7 @@ describe Dolt::Sinatra::Actions do
|
|
195
64
|
end
|
196
65
|
|
197
66
|
it "redirects ref to oid if configured so" do
|
198
|
-
app =
|
67
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
199
68
|
app.blob("gitorious", "master", "lib/gitorious.rb")
|
200
69
|
|
201
70
|
location = app.response["Location"]
|
@@ -207,8 +76,8 @@ describe Dolt::Sinatra::Actions do
|
|
207
76
|
|
208
77
|
describe "#tree" do
|
209
78
|
it "delegates to actions" do
|
210
|
-
actions = Actions.new(
|
211
|
-
app =
|
79
|
+
actions = Test::Actions.new(Stub::Tree.new)
|
80
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new)
|
212
81
|
app.tree("gitorious", "master", "app/models")
|
213
82
|
|
214
83
|
assert_equal "gitorious", actions.repo
|
@@ -217,7 +86,7 @@ describe Dolt::Sinatra::Actions do
|
|
217
86
|
end
|
218
87
|
|
219
88
|
it "renders the tree template as html" do
|
220
|
-
app =
|
89
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
221
90
|
app.tree("gitorious", "master", "app/models")
|
222
91
|
|
223
92
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -225,7 +94,7 @@ describe Dolt::Sinatra::Actions do
|
|
225
94
|
end
|
226
95
|
|
227
96
|
it "redirects blob views to blob action" do
|
228
|
-
app =
|
97
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Tree"))
|
229
98
|
app.tree("gitorious", "master", "app/models/repository.rb")
|
230
99
|
|
231
100
|
location = app.response["Location"]
|
@@ -235,21 +104,21 @@ describe Dolt::Sinatra::Actions do
|
|
235
104
|
end
|
236
105
|
|
237
106
|
it "sets X-UA-Compatible header" do
|
238
|
-
app =
|
107
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
239
108
|
app.tree("gitorious", "master", "app/models")
|
240
109
|
|
241
110
|
assert_equal "IE=edge", app.response["X-UA-Compatible"]
|
242
111
|
end
|
243
112
|
|
244
113
|
it "does not set cache-control header for head ref" do
|
245
|
-
app =
|
114
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
246
115
|
app.tree("gitorious", "master", "app/models")
|
247
116
|
|
248
117
|
assert !app.response.key?("Cache-Control")
|
249
118
|
end
|
250
119
|
|
251
120
|
it "sets cache headers for full oid ref" do
|
252
|
-
app =
|
121
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
253
122
|
app.tree("gitorious", "a" * 40, "app/models")
|
254
123
|
|
255
124
|
assert_equal "max-age=315360000, public", app.response["Cache-Control"]
|
@@ -257,15 +126,15 @@ describe Dolt::Sinatra::Actions do
|
|
257
126
|
end
|
258
127
|
|
259
128
|
it "unescapes ref" do
|
260
|
-
actions = Actions.new(
|
261
|
-
app =
|
129
|
+
actions = Test::Actions.new(Stub::Tree.new)
|
130
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Tree"))
|
262
131
|
app.tree("gitorious", "issue-%23221", "app")
|
263
132
|
|
264
133
|
assert_equal "issue-#221", actions.ref
|
265
134
|
end
|
266
135
|
|
267
136
|
it "redirects ref to oid if configured so" do
|
268
|
-
app =
|
137
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
269
138
|
app.tree("gitorious", "master", "lib")
|
270
139
|
|
271
140
|
assert_equal "/gitorious/tree/#{'a' * 40}:lib", app.response["Location"]
|
@@ -274,7 +143,7 @@ describe Dolt::Sinatra::Actions do
|
|
274
143
|
|
275
144
|
describe "#tree_entry" do
|
276
145
|
it "renders trees with the tree template as html" do
|
277
|
-
app =
|
146
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
278
147
|
app.tree_entry("gitorious", "master", "app/models")
|
279
148
|
|
280
149
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -282,7 +151,7 @@ describe Dolt::Sinatra::Actions do
|
|
282
151
|
end
|
283
152
|
|
284
153
|
it "renders trees with the tree template as html" do
|
285
|
-
app =
|
154
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
286
155
|
app.tree_entry("gitorious", "master", "app/models")
|
287
156
|
|
288
157
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -290,15 +159,15 @@ describe Dolt::Sinatra::Actions do
|
|
290
159
|
end
|
291
160
|
|
292
161
|
it "unescapes ref" do
|
293
|
-
actions = Actions.new(
|
294
|
-
app =
|
162
|
+
actions = Test::Actions.new(Stub::Tree.new)
|
163
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Tree"))
|
295
164
|
app.tree_entry("gitorious", "issue-%23221", "app")
|
296
165
|
|
297
166
|
assert_equal "issue-#221", actions.ref
|
298
167
|
end
|
299
168
|
|
300
169
|
it "redirects ref to oid if configured so" do
|
301
|
-
app =
|
170
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
302
171
|
app.tree_entry("gitorious", "master", "lib")
|
303
172
|
|
304
173
|
assert_equal "/gitorious/source/#{'a' * 40}:lib", app.response["Location"]
|
@@ -307,8 +176,8 @@ describe Dolt::Sinatra::Actions do
|
|
307
176
|
|
308
177
|
describe "#raw" do
|
309
178
|
it "delegates to actions" do
|
310
|
-
actions = Actions.new(
|
311
|
-
app =
|
179
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
180
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new)
|
312
181
|
app.raw("gitorious", "master", "app/models/repository.rb")
|
313
182
|
|
314
183
|
assert_equal "gitorious", actions.repo
|
@@ -317,7 +186,7 @@ describe Dolt::Sinatra::Actions do
|
|
317
186
|
end
|
318
187
|
|
319
188
|
it "renders the raw template as text" do
|
320
|
-
app =
|
189
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Text"))
|
321
190
|
app.raw("gitorious", "master", "app/models/repository.rb")
|
322
191
|
|
323
192
|
assert_equal "text/plain", app.response["Content-Type"]
|
@@ -325,7 +194,7 @@ describe Dolt::Sinatra::Actions do
|
|
325
194
|
end
|
326
195
|
|
327
196
|
it "redirects tree views to tree action" do
|
328
|
-
app =
|
197
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
329
198
|
app.raw("gitorious", "master", "app/models")
|
330
199
|
|
331
200
|
location = app.response["Location"]
|
@@ -335,15 +204,15 @@ describe Dolt::Sinatra::Actions do
|
|
335
204
|
end
|
336
205
|
|
337
206
|
it "unescapes ref" do
|
338
|
-
actions = Actions.new(
|
339
|
-
app =
|
207
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
208
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
340
209
|
app.raw("gitorious", "issue-%23221", "app/models/repository.rb")
|
341
210
|
|
342
211
|
assert_equal "issue-#221", actions.ref
|
343
212
|
end
|
344
213
|
|
345
214
|
it "redirects ref to oid if configured so" do
|
346
|
-
app =
|
215
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
347
216
|
app.raw("gitorious", "master", "lib/gitorious.rb")
|
348
217
|
|
349
218
|
assert_equal "/gitorious/raw/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
@@ -352,8 +221,8 @@ describe Dolt::Sinatra::Actions do
|
|
352
221
|
|
353
222
|
describe "#blame" do
|
354
223
|
it "delegates to actions" do
|
355
|
-
actions = Actions.new(
|
356
|
-
app =
|
224
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
225
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new)
|
357
226
|
app.blame("gitorious", "master", "app/models/repository.rb")
|
358
227
|
|
359
228
|
assert_equal "gitorious", actions.repo
|
@@ -362,7 +231,7 @@ describe Dolt::Sinatra::Actions do
|
|
362
231
|
end
|
363
232
|
|
364
233
|
it "renders the blame template as html" do
|
365
|
-
app =
|
234
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Text"))
|
366
235
|
app.blame("gitorious", "master", "app/models/repository.rb")
|
367
236
|
|
368
237
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -370,15 +239,15 @@ describe Dolt::Sinatra::Actions do
|
|
370
239
|
end
|
371
240
|
|
372
241
|
it "unescapes ref" do
|
373
|
-
actions = Actions.new(
|
374
|
-
app =
|
242
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
243
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
375
244
|
app.blame("gitorious", "issue-%23221", "app/models/repository.rb")
|
376
245
|
|
377
246
|
assert_equal "issue-#221", actions.ref
|
378
247
|
end
|
379
248
|
|
380
249
|
it "redirects ref to oid if configured so" do
|
381
|
-
app =
|
250
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
382
251
|
app.blame("gitorious", "master", "lib/gitorious.rb")
|
383
252
|
|
384
253
|
assert_equal "/gitorious/blame/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
@@ -387,8 +256,8 @@ describe Dolt::Sinatra::Actions do
|
|
387
256
|
|
388
257
|
describe "#history" do
|
389
258
|
it "delegates to actions" do
|
390
|
-
actions = Actions.new(
|
391
|
-
app =
|
259
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
260
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new)
|
392
261
|
app.history("gitorious", "master", "app/models/repository.rb", 10)
|
393
262
|
|
394
263
|
assert_equal "gitorious", actions.repo
|
@@ -397,7 +266,7 @@ describe Dolt::Sinatra::Actions do
|
|
397
266
|
end
|
398
267
|
|
399
268
|
it "renders the commits template as html" do
|
400
|
-
app =
|
269
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Text"))
|
401
270
|
app.history("gitorious", "master", "app/models/repository.rb", 10)
|
402
271
|
|
403
272
|
assert_equal "text/html; charset=utf-8", app.response["Content-Type"]
|
@@ -405,15 +274,15 @@ describe Dolt::Sinatra::Actions do
|
|
405
274
|
end
|
406
275
|
|
407
276
|
it "unescapes ref" do
|
408
|
-
actions = Actions.new(
|
409
|
-
app =
|
277
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
278
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Blob"))
|
410
279
|
app.history("gitorious", "issue-%23221", "lib/gitorious.rb", 10)
|
411
280
|
|
412
281
|
assert_equal "issue-#221", actions.ref
|
413
282
|
end
|
414
283
|
|
415
284
|
it "redirects ref to oid if configured so" do
|
416
|
-
app =
|
285
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("Blob"))
|
417
286
|
app.history("gitorious", "master", "lib/gitorious.rb", 10)
|
418
287
|
|
419
288
|
assert_equal "/gitorious/history/#{'a' * 40}:lib/gitorious.rb", app.response["Location"]
|
@@ -422,7 +291,7 @@ describe Dolt::Sinatra::Actions do
|
|
422
291
|
|
423
292
|
describe "#refs" do
|
424
293
|
it "renders the refs template as json" do
|
425
|
-
app =
|
294
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Blob.new), Test::Renderer.new("JSON"))
|
426
295
|
app.refs("gitorious")
|
427
296
|
|
428
297
|
assert_equal "application/json", app.response["Content-Type"]
|
@@ -432,7 +301,7 @@ describe Dolt::Sinatra::Actions do
|
|
432
301
|
|
433
302
|
describe "#tree_history" do
|
434
303
|
it "renders the tree_history template as json" do
|
435
|
-
app =
|
304
|
+
app = Test::SinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("JSON"))
|
436
305
|
app.tree_history("gitorious", "master", "", 1)
|
437
306
|
|
438
307
|
assert_equal "application/json", app.response["Content-Type"]
|
@@ -440,15 +309,15 @@ describe Dolt::Sinatra::Actions do
|
|
440
309
|
end
|
441
310
|
|
442
311
|
it "unescapes ref" do
|
443
|
-
actions = Actions.new(
|
444
|
-
app =
|
312
|
+
actions = Test::Actions.new(Stub::Tree.new)
|
313
|
+
app = Test::SinatraApp.new(actions, Test::Renderer.new("Tree"))
|
445
314
|
app.tree_history("gitorious", "issue-%23221", "app/models")
|
446
315
|
|
447
316
|
assert_equal "issue-#221", actions.ref
|
448
317
|
end
|
449
318
|
|
450
319
|
it "redirects ref to oid if configured so" do
|
451
|
-
app =
|
320
|
+
app = Test::RedirectingSinatraApp.new(Test::Actions.new(Stub::Tree.new), Test::Renderer.new("Tree"))
|
452
321
|
app.tree_history("gitorious", "master", "lib", 10)
|
453
322
|
|
454
323
|
assert_equal "/gitorious/tree_history/#{'a' * 40}:lib", app.response["Location"]
|
@@ -0,0 +1,41 @@
|
|
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 "test_helper"
|
19
|
+
require "rack/test"
|
20
|
+
require "pathname"
|
21
|
+
require "tiltout"
|
22
|
+
require "libdolt"
|
23
|
+
require "dolt/sinatra/multi_repo_browser"
|
24
|
+
|
25
|
+
ENV["RACK_ENV"] = "test"
|
26
|
+
|
27
|
+
describe Dolt::Sinatra::MultiRepoBrowser do
|
28
|
+
include Rack::Test::Methods
|
29
|
+
|
30
|
+
def app
|
31
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
32
|
+
def actions.repositories; []; end
|
33
|
+
view = Tiltout.new(Dolt.template_dir)
|
34
|
+
Dolt::Sinatra::MultiRepoBrowser.new(actions, view)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "serves the index" do
|
38
|
+
get "/"
|
39
|
+
assert_equal 200, last_response.status
|
40
|
+
end
|
41
|
+
end
|
@@ -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 "test_helper"
|
19
|
+
require "rack/test"
|
20
|
+
require "pathname"
|
21
|
+
require "tiltout"
|
22
|
+
require "libdolt"
|
23
|
+
require "dolt/sinatra/single_repo_browser"
|
24
|
+
|
25
|
+
ENV["RACK_ENV"] = "test"
|
26
|
+
|
27
|
+
describe Dolt::Sinatra::SingleRepoBrowser do
|
28
|
+
include Rack::Test::Methods
|
29
|
+
|
30
|
+
def app
|
31
|
+
dir = Pathname("../../../").realpath.to_s
|
32
|
+
actions = Test::Actions.new(Stub::Blob.new)
|
33
|
+
view = Tiltout.new(Dolt.template_dir)
|
34
|
+
Dolt::Sinatra::SingleRepoBrowser.new(dir, actions, view)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "serves the index" do
|
38
|
+
get "/"
|
39
|
+
|
40
|
+
assert_equal 302, last_response.status
|
41
|
+
end
|
42
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -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
|
@@ -17,9 +17,8 @@
|
|
17
17
|
#++
|
18
18
|
require "bundler/setup"
|
19
19
|
require "minitest/autorun"
|
20
|
-
require "em/minitest/spec"
|
21
|
-
require "eventmachine"
|
22
20
|
require "libdolt/view"
|
21
|
+
require "dolt/sinatra/actions"
|
23
22
|
require "tiltout"
|
24
23
|
|
25
24
|
Bundler.require(:default, :test)
|
@@ -36,15 +35,150 @@ module Dolt
|
|
36
35
|
root = File.join(File.dirname(__FILE__), "..", "views")
|
37
36
|
renderer = Tiltout.new(root, options)
|
38
37
|
renderer.helper(helpers || [Dolt::View::MultiRepository,
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
Dolt::View::Object,
|
39
|
+
Dolt::View::Blob,
|
40
|
+
Dolt::View::Tree,
|
41
|
+
Dolt::View::Blame,
|
42
|
+
Dolt::View::SyntaxHighlight,
|
43
|
+
Dolt::View::Commit,
|
44
|
+
Dolt::View::Gravatar,
|
45
|
+
Dolt::View::Breadcrumb])
|
47
46
|
renderer
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
50
|
+
|
51
|
+
module Stub
|
52
|
+
class Blob
|
53
|
+
def is_a?(type)
|
54
|
+
type == Rugged::Blob
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Tree
|
59
|
+
def is_a?(type)
|
60
|
+
type == Rugged::Tree
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module Test
|
66
|
+
class SinatraApp
|
67
|
+
include Dolt::Sinatra::Actions
|
68
|
+
attr_reader :actions, :renderer
|
69
|
+
|
70
|
+
def initialize(actions, renderer)
|
71
|
+
@actions = actions
|
72
|
+
@renderer = renderer
|
73
|
+
end
|
74
|
+
|
75
|
+
def body(str = nil)
|
76
|
+
@body = str if !str.nil?
|
77
|
+
@body
|
78
|
+
end
|
79
|
+
|
80
|
+
def response
|
81
|
+
if !@response
|
82
|
+
@response = {}
|
83
|
+
def @response.status; @status; end
|
84
|
+
def @response.status=(status); @status = status; end
|
85
|
+
end
|
86
|
+
@response
|
87
|
+
end
|
88
|
+
|
89
|
+
def tree_url(repo, ref, path)
|
90
|
+
"/#{repo}/tree/#{ref}:#{path}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def blob_url(repo, ref, path)
|
94
|
+
"/#{repo}/blob/#{ref}:#{path}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def tree_entry_url(repo, ref, path)
|
98
|
+
"/#{repo}/source/#{ref}:#{path}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def blame_url(repo, ref, path)
|
102
|
+
"/#{repo}/blame/#{ref}:#{path}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def history_url(repo, ref, path)
|
106
|
+
"/#{repo}/history/#{ref}:#{path}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def tree_history_url(repo, ref, path)
|
110
|
+
"/#{repo}/tree_history/#{ref}:#{path}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def raw_url(repo, ref, path)
|
114
|
+
"/#{repo}/raw/#{ref}:#{path}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class RedirectingSinatraApp < SinatraApp
|
119
|
+
def redirect_refs?; true; end
|
120
|
+
end
|
121
|
+
|
122
|
+
class Renderer
|
123
|
+
def initialize(body = ""); @body = body; end
|
124
|
+
|
125
|
+
def render(action, data, options = {})
|
126
|
+
@action = action
|
127
|
+
@data = data
|
128
|
+
"#{action}:#@body"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
class Actions
|
133
|
+
attr_reader :repo, :ref, :path
|
134
|
+
|
135
|
+
def initialize(response)
|
136
|
+
@response = response
|
137
|
+
end
|
138
|
+
|
139
|
+
def blob(repo, ref, path)
|
140
|
+
respond(:blob, repo, ref, path)
|
141
|
+
end
|
142
|
+
|
143
|
+
def tree(repo, ref, path)
|
144
|
+
respond(:tree, repo, ref, path)
|
145
|
+
end
|
146
|
+
|
147
|
+
def tree_entry(repo, ref, path)
|
148
|
+
respond(:tree_entry, repo, ref, path)
|
149
|
+
end
|
150
|
+
|
151
|
+
def raw(repo, ref, path)
|
152
|
+
respond(:raw, repo, ref, path)
|
153
|
+
end
|
154
|
+
|
155
|
+
def blame(repo, ref, path)
|
156
|
+
respond(:blame, repo, ref, path)
|
157
|
+
end
|
158
|
+
|
159
|
+
def history(repo, ref, path, limit)
|
160
|
+
respond(:history, repo, ref, path)
|
161
|
+
end
|
162
|
+
|
163
|
+
def refs(repo)
|
164
|
+
respond(:refs, repo)
|
165
|
+
end
|
166
|
+
|
167
|
+
def tree_history(repo, ref, path, count)
|
168
|
+
respond(:tree_history, repo, ref, path)
|
169
|
+
end
|
170
|
+
|
171
|
+
def respond(type, repo, ref = nil, path = nil)
|
172
|
+
@repo = repo
|
173
|
+
@ref = ref
|
174
|
+
@path = path
|
175
|
+
data = { :ref => ref, :repository => repo }
|
176
|
+
data[type != :tree_entry ? type : (@response.class.to_s =~ /Tree/ ? :tree : :blob)] = @response
|
177
|
+
data
|
178
|
+
end
|
179
|
+
|
180
|
+
def rev_parse_oid(repo, ref)
|
181
|
+
"a" * 40
|
182
|
+
end
|
183
|
+
end
|
184
|
+
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.12.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-
|
12
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libdolt
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0.
|
21
|
+
version: '0.17'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.17'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: thin
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,22 +59,6 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: async_sinatra
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.0'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.0'
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
name: tiltout
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,13 +108,13 @@ dependencies:
|
|
124
108
|
- !ruby/object:Gem::Version
|
125
109
|
version: '2.0'
|
126
110
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
111
|
+
name: rake
|
128
112
|
requirement: !ruby/object:Gem::Requirement
|
129
113
|
none: false
|
130
114
|
requirements:
|
131
115
|
- - ~>
|
132
116
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
117
|
+
version: '0.9'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,15 +122,15 @@ dependencies:
|
|
138
122
|
requirements:
|
139
123
|
- - ~>
|
140
124
|
- !ruby/object:Gem::Version
|
141
|
-
version: '
|
125
|
+
version: '0.9'
|
142
126
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
127
|
+
name: rack-test
|
144
128
|
requirement: !ruby/object:Gem::Requirement
|
145
129
|
none: false
|
146
130
|
requirements:
|
147
131
|
- - ~>
|
148
132
|
- !ruby/object:Gem::Version
|
149
|
-
version: '0.
|
133
|
+
version: '0.6'
|
150
134
|
type: :development
|
151
135
|
prerelease: false
|
152
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +138,7 @@ dependencies:
|
|
154
138
|
requirements:
|
155
139
|
- - ~>
|
156
140
|
- !ruby/object:Gem::Version
|
157
|
-
version: '0.
|
141
|
+
version: '0.6'
|
158
142
|
description: Dolt serves git trees and syntax highlighted blobs
|
159
143
|
email:
|
160
144
|
- christian@gitorious.org
|
@@ -175,6 +159,8 @@ files:
|
|
175
159
|
- ./lib/dolt/sinatra/multi_repo_browser.rb
|
176
160
|
- ./lib/dolt/sinatra/single_repo_browser.rb
|
177
161
|
- ./test/dolt/sinatra/actions_test.rb
|
162
|
+
- ./test/dolt/sinatra/multi_repo_browser_test.rb
|
163
|
+
- ./test/dolt/sinatra/single_repo_browser_test.rb
|
178
164
|
- ./test/test_helper.rb
|
179
165
|
- vendor/ui/.gitignore
|
180
166
|
- vendor/ui/.gitmodules
|