dolt 0.25.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dolt (0.25.0)
4
+ dolt (0.26.0)
5
5
  json (~> 1.5)
6
- libdolt (~> 0.23)
6
+ libdolt (~> 0.26)
7
7
  sinatra (~> 1.0)
8
8
  thin (~> 1.4)
9
9
  tiltout (~> 1.4)
@@ -13,29 +13,37 @@ GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
15
  builder (3.2.2)
16
+ charlock_holmes (0.6.9.4)
16
17
  ci_reporter (1.9.0)
17
18
  builder (>= 2.1.2)
18
19
  daemons (1.1.9)
20
+ escape_utils (0.3.2)
19
21
  eventmachine (1.0.3)
22
+ github-linguist (2.8.5)
23
+ charlock_holmes (~> 0.6.6)
24
+ escape_utils (~> 0.3.1)
25
+ mime-types (~> 1.19)
26
+ pygments.rb (~> 0.4.2)
20
27
  github-markup (0.7.5)
21
28
  htmlentities (4.3.1)
22
29
  json (1.8.0)
23
- libdolt (0.24.0)
30
+ libdolt (0.26.0)
24
31
  htmlentities (~> 4.3)
25
32
  json (~> 1.7)
26
- makeup (~> 0.2)
33
+ makeup (~> 0.4)
27
34
  mime-types (~> 1.19)
28
35
  rugged (= 0.18.0.gh.de28323)
29
36
  tzinfo (~> 0.3)
30
- makeup (0.3.0)
37
+ makeup (0.4.0)
38
+ github-linguist (~> 2.8)
31
39
  github-markup (~> 0.7)
32
40
  htmlentities (~> 4.3)
33
- pygments.rb (~> 0.2)
41
+ pygments.rb (~> 0.4)
34
42
  mime-types (1.23)
35
43
  minitest (2.12.1)
36
44
  multi_json (1.7.7)
37
45
  posix-spawn (0.3.6)
38
- pygments.rb (0.5.1)
46
+ pygments.rb (0.4.2)
39
47
  posix-spawn (~> 0.3.6)
40
48
  yajl-ruby (~> 1.1.0)
41
49
  rack (1.5.2)
data/bin/dolt CHANGED
@@ -21,16 +21,16 @@ class DoltApp
21
21
  if is_git_repo?(dir)
22
22
  dir = File.expand_path(dir)
23
23
  resolver = Dolt::DiskRepoResolver.new(File.dirname(dir))
24
- actions = Dolt::RepoActions.new(resolver)
24
+ lookup = Dolt::RepositoryLookup.new(resolver)
25
25
  view.helper(Dolt::View::SingleRepository)
26
26
  require "dolt/sinatra/single_repo_browser"
27
- Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), actions, view)
27
+ Dolt::Sinatra::SingleRepoBrowser.new(File.basename(dir), lookup, view)
28
28
  else
29
29
  resolver = Dolt::DiskRepoResolver.new(dir)
30
- actions = Dolt::RepoActions.new(resolver)
30
+ lookup = Dolt::RepositoryLookup.new(resolver)
31
31
  view.helper(Dolt::View::MultiRepository)
32
32
  require "dolt/sinatra/multi_repo_browser"
33
- Dolt::Sinatra::MultiRepoBrowser.new(actions, view)
33
+ Dolt::Sinatra::MultiRepoBrowser.new(lookup, view)
34
34
  end
35
35
  end
36
36
 
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.25.0"
14
+ s.version = "0.26.0"
15
15
  s.authors = ["Christian Johansen"]
16
16
  s.email = ["christian@gitorious.org"]
17
17
  s.homepage = "http://gitorious.org/gitorious/dolt"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.rubyforge_project = "dolt"
22
22
 
23
- s.add_dependency "libdolt", "~>0.23"
23
+ s.add_dependency "libdolt", "~>0.26"
24
24
  s.add_dependency "thin", "~>1.4"
25
25
  s.add_dependency "sinatra", "~>1.0"
26
26
  s.add_dependency "tiltout", "~>1.4"
@@ -21,32 +21,38 @@ require "cgi"
21
21
 
22
22
  module Dolt
23
23
  module Sinatra
24
- module Actions
24
+ class Actions
25
+ def initialize(app, lookup, renderer)
26
+ @app = app
27
+ @lookup = lookup
28
+ @renderer = renderer
29
+ end
30
+
25
31
  def redirect(url, status = 302)
26
- response.status = status
27
- response["Location"] = url
28
- body ""
32
+ app.response.status = status
33
+ app.response["Location"] = url
34
+ app.body("")
29
35
  end
30
36
 
31
37
  def render_error(error, repo, ref, data = {})
32
38
  if error.class.to_s == "Rugged::ReferenceError" && ref == "HEAD"
33
- return body(renderer.render("empty", {
39
+ return app.body(renderer.render("empty", {
34
40
  :repository => repo,
35
41
  :ref => ref
36
42
  }.merge(data)))
37
43
  end
38
44
  template = error.class.to_s == "Rugged::IndexerError" ? :"404" : :"500"
39
- add_headers(response)
40
- body(renderer.render(template, {
41
- :error => error,
42
- :repository_slug => repo,
43
- :ref => ref
44
- }.merge(data)))
45
+ add_headers(app.response)
46
+ app.body(renderer.render(template, {
47
+ :error => error,
48
+ :repository_slug => repo,
49
+ :ref => ref
50
+ }.merge(data)))
45
51
  rescue Exception => err
46
52
  err_backtrace = err.backtrace.map { |s| "<li>#{s}</li>" }
47
53
  error_backtrace = error.backtrace.map { |s| "<li>#{s}</li>" }
48
54
 
49
- body(<<-HTML)
55
+ app.body(<<-HTML)
50
56
  <h1>Fatal Dolt Error</h1>
51
57
  <p>
52
58
  Dolt encountered an exception, and additionally
@@ -68,98 +74,100 @@ module Dolt
68
74
 
69
75
  def raw(repo, ref, path, custom_data = {})
70
76
  if oid = lookup_ref_oid(repo, ref)
71
- redirect(raw_url(repo, oid, path), 307) and return
77
+ redirect(app.raw_url(repo, oid, path), 307) and return
72
78
  end
73
79
 
74
80
  blob(repo, ref, path, custom_data, {
75
- :template => :raw,
76
- :content_type => "text/plain",
77
- :template_options => { :layout => nil }
78
- })
81
+ :template => :raw,
82
+ :content_type => "text/plain",
83
+ :template_options => { :layout => nil }
84
+ })
79
85
  end
80
86
 
81
87
  def blob(repo, ref, path, custom_data = {}, options = { :template => :blob })
82
88
  if oid = lookup_ref_oid(repo, ref)
83
- redirect(blob_url(repo, oid, path), 307) and return
89
+ redirect(app.blob_url(repo, oid, path), 307) and return
84
90
  end
85
91
 
86
- data = (custom_data || {}).merge(actions.blob(repo, u(ref), path))
92
+ data = (custom_data || {}).merge(lookup.blob(repo, u(ref), path))
87
93
  blob = data[:blob]
88
- return redirect(tree_url(repo, ref, path)) if blob.class.to_s !~ /\bBlob/
89
- add_headers(response, options.merge(:ref => ref))
94
+ return redirect(app.tree_url(repo, ref, path)) if blob.class.to_s !~ /\bBlob/
95
+ add_headers(app.response, options.merge(:ref => ref))
90
96
  tpl_options = options[:template_options] || {}
91
- body(renderer.render(options[:template], data, tpl_options))
97
+ app.body(renderer.render(options[:template], data, tpl_options))
92
98
  end
93
99
 
94
100
  def tree(repo, ref, path, custom_data = {})
95
101
  if oid = lookup_ref_oid(repo, ref)
96
- redirect(tree_url(repo, oid, path), 307) and return
102
+ redirect(app.tree_url(repo, oid, path), 307) and return
97
103
  end
98
104
 
99
- data = (custom_data || {}).merge(actions.tree(repo, u(ref), path))
105
+ data = (custom_data || {}).merge(lookup.tree(repo, u(ref), path))
100
106
  tree = data[:tree]
101
- return redirect(blob_url(repo, ref, path)) if tree.class.to_s !~ /\bTree/
102
- add_headers(response, :ref => ref)
103
- body(renderer.render(:tree, data))
107
+ return redirect(app.blob_url(repo, ref, path)) if tree.class.to_s !~ /\bTree/
108
+ add_headers(app.response, :ref => ref)
109
+ app.body(renderer.render(:tree, data))
104
110
  end
105
111
 
106
112
  def tree_entry(repo, ref, path, custom_data = {})
107
113
  if oid = lookup_ref_oid(repo, ref)
108
- redirect(tree_entry_url(repo, oid, path), 307) and return
114
+ redirect(app.tree_entry_url(repo, oid, path), 307) and return
109
115
  end
110
116
 
111
- data = (custom_data || {}).merge(actions.tree_entry(repo, u(ref), path))
112
- add_headers(response, :ref => ref)
113
- body(renderer.render(data.key?(:tree) ? :tree : :blob, data))
117
+ data = (custom_data || {}).merge(lookup.tree_entry(repo, u(ref), path))
118
+ add_headers(app.response, :ref => ref)
119
+ app.body(renderer.render(data.key?(:tree) ? :tree : :blob, data))
114
120
  end
115
121
 
116
122
  def blame(repo, ref, path, custom_data = {})
117
123
  if oid = lookup_ref_oid(repo, ref)
118
- redirect(blame_url(repo, oid, path), 307) and return
124
+ redirect(app.blame_url(repo, oid, path), 307) and return
119
125
  end
120
126
 
121
- data = (custom_data || {}).merge(actions.blame(repo, u(ref), path))
122
- add_headers(response, :ref => ref)
123
- body(renderer.render(:blame, data))
127
+ data = (custom_data || {}).merge(lookup.blame(repo, u(ref), path))
128
+ add_headers(app.response, :ref => ref)
129
+ app.body(renderer.render(:blame, data))
124
130
  end
125
131
 
126
132
  def history(repo, ref, path, count, custom_data = {})
127
133
  if oid = lookup_ref_oid(repo, ref)
128
- redirect(history_url(repo, oid, path), 307) and return
134
+ redirect(app.history_url(repo, oid, path), 307) and return
129
135
  end
130
136
 
131
- data = (custom_data || {}).merge(actions.history(repo, u(ref), path, count))
132
- add_headers(response, :ref => ref)
133
- body(renderer.render(:commits, data))
137
+ data = (custom_data || {}).merge(lookup.history(repo, u(ref), path, count))
138
+ add_headers(app.response, :ref => ref)
139
+ app.body(renderer.render(:commits, data))
134
140
  end
135
141
 
136
142
  def refs(repo, custom_data = {})
137
- data = (custom_data || {}).merge(actions.refs(repo))
138
- add_headers(response, :content_type => "application/json")
139
- body(renderer.render(:refs, data, :layout => nil))
143
+ data = (custom_data || {}).merge(lookup.refs(repo))
144
+ add_headers(app.response, :content_type => "application/json")
145
+ app.body(renderer.render(:refs, data, :layout => nil))
140
146
  end
141
147
 
142
148
  def tree_history(repo, ref, path, count = 1, custom_data = {})
143
149
  if oid = lookup_ref_oid(repo, ref)
144
- redirect(tree_history_url(repo, oid, path), 307) and return
150
+ redirect(app.tree_history_url(repo, oid, path), 307) and return
145
151
  end
146
152
 
147
- data = (custom_data || {}).merge(actions.tree_history(repo, u(ref), path, count))
148
- add_headers(response, :content_type => "application/json", :ref => ref)
149
- body(renderer.render(:tree_history, data, :layout => nil))
153
+ data = (custom_data || {}).merge(lookup.tree_history(repo, u(ref), path, count))
154
+ add_headers(app.response, :content_type => "application/json", :ref => ref)
155
+ app.body(renderer.render(:tree_history, data, :layout => nil))
150
156
  end
151
157
 
152
158
  def resolve_repository(repo)
153
159
  @cache ||= {}
154
- @cache[repo] ||= actions.resolve_repository(repo)
160
+ @cache[repo] ||= lookup.resolve_repository(repo)
155
161
  end
156
162
 
157
163
  def lookup_ref_oid(repo, ref)
158
- return if !respond_to?(:redirect_refs?) || !redirect_refs? || ref.length == 40
159
- actions.rev_parse_oid(repo, ref)
164
+ return if !app.respond_to?(:redirect_refs?) || !app.redirect_refs? || ref.length == 40
165
+ lookup.rev_parse_oid(repo, ref)
160
166
  end
161
167
 
162
168
  private
169
+ attr_reader :app, :lookup, :renderer
170
+
163
171
  def u(str)
164
172
  # Temporarily swap the + out with a magic byte, so
165
173
  # filenames/branches with +'s won't get unescaped to a space
@@ -15,23 +15,31 @@
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 "dolt/sinatra/base"
18
+ require "sinatra/base"
19
+ require "dolt/sinatra/actions"
19
20
  require "libdolt/view/multi_repository"
20
21
  require "libdolt/view/blob"
21
22
  require "libdolt/view/tree"
22
23
 
23
24
  module Dolt
24
25
  module Sinatra
25
- class MultiRepoBrowser < Dolt::Sinatra::Base
26
+ class MultiRepoBrowser < ::Sinatra::Base
26
27
  include Dolt::View::MultiRepository
27
28
  include Dolt::View::Blob
28
29
  include Dolt::View::Tree
29
30
 
31
+ def initialize(lookup, renderer)
32
+ @lookup = lookup
33
+ @renderer = renderer
34
+ @dolt = Dolt::Sinatra::Actions.new(self, lookup, renderer)
35
+ super()
36
+ end
37
+
30
38
  not_found { renderer.render("404") }
31
39
 
32
40
  get "/" do
33
41
  response["Content-Type"] = "text/html"
34
- body(renderer.render(:index, { :repositories => actions.repositories }))
42
+ body(renderer.render(:index, { :repositories => lookup.repositories }))
35
43
  end
36
44
 
37
45
  get "/:repo" do
@@ -41,86 +49,88 @@ module Dolt
41
49
  get "/*/tree/*:*" do
42
50
  begin
43
51
  repo, ref, path = params[:splat]
44
- tree(repo, ref, path)
52
+ dolt.tree(repo, ref, path)
45
53
  rescue Exception => err
46
- render_error(err, repo, ref)
54
+ dolt.render_error(err, repo, ref)
47
55
  end
48
56
  end
49
57
 
50
58
  get "/*/tree/*" do
51
- force_ref(params[:splat], "tree", "HEAD")
59
+ dolt.force_ref(params[:splat], "tree", "HEAD")
52
60
  end
53
61
 
54
62
  get "/*/blob/*:*" do
55
63
  begin
56
64
  repo, ref, path = params[:splat]
57
- blob(repo, ref, path)
65
+ dolt.blob(repo, ref, path)
58
66
  rescue Exception => err
59
- render_error(err, repo, ref)
67
+ dolt.render_error(err, repo, ref)
60
68
  end
61
69
  end
62
70
 
63
71
  get "/*/blob/*" do
64
- force_ref(params[:splat], "blob", "HEAD")
72
+ dolt.force_ref(params[:splat], "blob", "HEAD")
65
73
  end
66
74
 
67
75
  get "/*/raw/*:*" do
68
76
  begin
69
77
  repo, ref, path = params[:splat]
70
- raw(repo, ref, path)
78
+ dolt.raw(repo, ref, path)
71
79
  rescue Exception => err
72
- render_error(err, repo, ref)
80
+ dolt.render_error(err, repo, ref)
73
81
  end
74
82
  end
75
83
 
76
84
  get "/*/raw/*" do
77
- force_ref(params[:splat], "raw", "HEAD")
85
+ dolt.force_ref(params[:splat], "raw", "HEAD")
78
86
  end
79
87
 
80
88
  get "/*/blame/*:*" do
81
89
  begin
82
90
  repo, ref, path = params[:splat]
83
- blame(repo, ref, path)
91
+ dolt.blame(repo, ref, path)
84
92
  rescue Exception => err
85
- render_error(err, repo, ref)
93
+ dolt.render_error(err, repo, ref)
86
94
  end
87
95
  end
88
96
 
89
97
  get "/*/blame/*" do
90
- force_ref(params[:splat], "blame", "HEAD")
98
+ dolt.force_ref(params[:splat], "blame", "HEAD")
91
99
  end
92
100
 
93
101
  get "/*/history/*:*" do
94
102
  begin
95
103
  repo, ref, path = params[:splat]
96
- history(repo, ref, path, (params[:commit_count] || 20).to_i)
104
+ dolt.history(repo, ref, path, (params[:commit_count] || 20).to_i)
97
105
  rescue Exception => err
98
- render_error(err, repo, ref)
106
+ dolt.render_error(err, repo, ref)
99
107
  end
100
108
  end
101
109
 
102
110
  get "/*/history/*" do
103
- force_ref(params[:splat], "history", "HEAD")
111
+ dolt.force_ref(params[:splat], "history", "HEAD")
104
112
  end
105
113
 
106
114
  get "/*/refs" do
107
115
  begin
108
- refs(params[:splat].first)
116
+ dolt.refs(params[:splat].first)
109
117
  rescue Exception => err
110
- render_error(err, repo, nil)
118
+ dolt.render_error(err, repo, nil)
111
119
  end
112
120
  end
113
121
 
114
122
  get "/*/tree_history/*:*" do
115
123
  begin
116
124
  repo, ref, path = params[:splat]
117
- tree_history(repo, ref, path)
125
+ dolt.tree_history(repo, ref, path)
118
126
  rescue Exception => err
119
- render_error(err, repo, ref)
127
+ dolt.render_error(err, repo, ref)
120
128
  end
121
129
  end
122
130
 
123
131
  private
132
+ attr_reader :repo, :lookup, :renderer, :dolt
133
+
124
134
  def force_ref(args, action, ref)
125
135
  redirect(args.shift + "/#{action}/#{ref}:" + args.join)
126
136
  end
@@ -15,22 +15,25 @@
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 "dolt/sinatra/base"
18
+ require "sinatra/base"
19
+ require "dolt/sinatra/actions"
19
20
  require "libdolt/view/single_repository"
20
21
  require "libdolt/view/blob"
21
22
  require "libdolt/view/tree"
22
23
 
23
24
  module Dolt
24
25
  module Sinatra
25
- class SingleRepoBrowser < Dolt::Sinatra::Base
26
+ class SingleRepoBrowser < ::Sinatra::Base
26
27
  include Dolt::View::SingleRepository
27
28
  include Dolt::View::Blob
28
29
  include Dolt::View::Tree
29
- attr_reader :repo
30
30
 
31
- def initialize(repo, actions, renderer)
31
+ def initialize(repo, lookup, renderer)
32
32
  @repo = repo
33
- super(actions, renderer)
33
+ @lookup = lookup
34
+ @renderer = renderer
35
+ @dolt = Dolt::Sinatra::Actions.new(self, lookup, renderer)
36
+ super()
34
37
  end
35
38
 
36
39
  not_found { renderer.render("404") }
@@ -42,86 +45,88 @@ module Dolt
42
45
  get "/tree/*:*" do
43
46
  begin
44
47
  ref, path = params[:splat]
45
- tree(repo, ref, path)
48
+ dolt.tree(repo, ref, path)
46
49
  rescue Exception => err
47
- render_error(err, repo, ref)
50
+ dolt.render_error(err, repo, ref)
48
51
  end
49
52
  end
50
53
 
51
54
  get "/tree/*" do
52
- force_ref(params[:splat], "tree", "HEAD")
55
+ dolt.force_ref(params[:splat], "tree", "HEAD")
53
56
  end
54
57
 
55
58
  get "/blob/*:*" do
56
59
  begin
57
60
  ref, path = params[:splat]
58
- blob(repo, ref, path)
61
+ dolt.blob(repo, ref, path)
59
62
  rescue Exception => err
60
- render_error(err, repo, ref)
63
+ dolt.render_error(err, repo, ref)
61
64
  end
62
65
  end
63
66
 
64
67
  get "/blob/*" do
65
- force_ref(params[:splat], "blob", "HEAD")
68
+ dolt.force_ref(params[:splat], "blob", "HEAD")
66
69
  end
67
70
 
68
71
  get "/raw/*:*" do
69
72
  begin
70
73
  ref, path = params[:splat]
71
- raw(repo, ref, path)
74
+ dolt.raw(repo, ref, path)
72
75
  rescue Exception => err
73
- render_error(err, repo, ref)
76
+ dolt.render_error(err, repo, ref)
74
77
  end
75
78
  end
76
79
 
77
80
  get "/raw/*" do
78
- force_ref(params[:splat], "raw", "HEAD")
81
+ dolt.force_ref(params[:splat], "raw", "HEAD")
79
82
  end
80
83
 
81
84
  get "/blame/*:*" do
82
85
  begin
83
86
  ref, path = params[:splat]
84
- blame(repo, ref, path)
87
+ dolt.blame(repo, ref, path)
85
88
  rescue Exception => err
86
- render_error(err, repo, ref)
89
+ dolt.render_error(err, repo, ref)
87
90
  end
88
91
  end
89
92
 
90
93
  get "/blame/*" do
91
- force_ref(params[:splat], "blame", "HEAD")
94
+ dolt.force_ref(params[:splat], "blame", "HEAD")
92
95
  end
93
96
 
94
97
  get "/history/*:*" do
95
98
  begin
96
99
  ref, path = params[:splat]
97
- history(repo, ref, path, (params[:commit_count] || 20).to_i)
100
+ dolt.history(repo, ref, path, (params[:commit_count] || 20).to_i)
98
101
  rescue Exception => err
99
- render_error(err, repo, ref)
102
+ dolt.render_error(err, repo, ref)
100
103
  end
101
104
  end
102
105
 
103
106
  get "/history/*" do
104
- force_ref(params[:splat], "blame", "HEAD")
107
+ dolt.force_ref(params[:splat], "blame", "HEAD")
105
108
  end
106
109
 
107
110
  get "/refs" do
108
111
  begin
109
- refs(repo)
112
+ dolt.refs(repo)
110
113
  rescue Exception => err
111
- render_error(err, repo, ref)
114
+ dolt.render_error(err, repo, ref)
112
115
  end
113
116
  end
114
117
 
115
118
  get "/tree_history/*:*" do
116
119
  begin
117
120
  ref, path = params[:splat]
118
- tree_history(repo, ref, path)
121
+ dolt.tree_history(repo, ref, path)
119
122
  rescue Exception => err
120
- render_error(err, repo, ref)
123
+ dolt.render_error(err, repo, ref)
121
124
  end
122
125
  end
123
126
 
124
127
  private
128
+ attr_reader :repo, :lookup, :renderer, :dolt
129
+
125
130
  def force_ref(args, action, ref)
126
131
  redirect("/#{action}/#{ref}:" + args.join)
127
132
  end