dolt 0.5.1 → 0.6.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.
Files changed (71) hide show
  1. data/Gemfile.lock +21 -18
  2. data/Readme.md +3 -5
  3. data/bin/dolt +3 -6
  4. data/dolt.gemspec +5 -16
  5. data/lib/dolt/sinatra/multi_repo_browser.rb +3 -3
  6. data/lib/dolt/sinatra/single_repo_browser.rb +3 -3
  7. data/test/test_helper.rb +5 -3
  8. data/vendor/ui/css/gitorious.css +5 -0
  9. metadata +23 -239
  10. data/lib/dolt/async/when.rb +0 -128
  11. data/lib/dolt/disk_repo_resolver.rb +0 -39
  12. data/lib/dolt/git/blame.rb +0 -112
  13. data/lib/dolt/git/commit.rb +0 -73
  14. data/lib/dolt/git/repository.rb +0 -139
  15. data/lib/dolt/git/submodule.rb +0 -35
  16. data/lib/dolt/git/tree.rb +0 -42
  17. data/lib/dolt/repo_actions.rb +0 -91
  18. data/lib/dolt/template_renderer.rb +0 -67
  19. data/lib/dolt/version.rb +0 -21
  20. data/lib/dolt/view.rb +0 -23
  21. data/lib/dolt/view/binary_blob_embedder.rb +0 -41
  22. data/lib/dolt/view/blame.rb +0 -57
  23. data/lib/dolt/view/blob.rb +0 -97
  24. data/lib/dolt/view/breadcrumb.rb +0 -47
  25. data/lib/dolt/view/commit.rb +0 -27
  26. data/lib/dolt/view/gravatar.rb +0 -29
  27. data/lib/dolt/view/markup.rb +0 -107
  28. data/lib/dolt/view/multi_repository.rb +0 -27
  29. data/lib/dolt/view/object.rb +0 -44
  30. data/lib/dolt/view/single_repository.rb +0 -27
  31. data/lib/dolt/view/smart_blob_renderer.rb +0 -33
  32. data/lib/dolt/view/syntax_highlight.rb +0 -90
  33. data/lib/dolt/view/tab_width.rb +0 -30
  34. data/lib/dolt/view/tree.rb +0 -100
  35. data/test/dolt/async/when_test.rb +0 -112
  36. data/test/dolt/git/blame_test.rb +0 -128
  37. data/test/dolt/git/commit_test.rb +0 -89
  38. data/test/dolt/git/repository_test.rb +0 -186
  39. data/test/dolt/repo_actions_test.rb +0 -236
  40. data/test/dolt/template_renderer_test.rb +0 -122
  41. data/test/dolt/templates/blame_test.rb +0 -56
  42. data/test/dolt/templates/blob_test.rb +0 -118
  43. data/test/dolt/templates/commits_test.rb +0 -61
  44. data/test/dolt/templates/raw_test.rb +0 -41
  45. data/test/dolt/templates/refs_test.rb +0 -38
  46. data/test/dolt/templates/tree_history_test.rb +0 -93
  47. data/test/dolt/templates/tree_test.rb +0 -65
  48. data/test/dolt/view/binary_blob_embedder_test.rb +0 -49
  49. data/test/dolt/view/blame_test.rb +0 -122
  50. data/test/dolt/view/blob_test.rb +0 -116
  51. data/test/dolt/view/breadcrumb_test.rb +0 -46
  52. data/test/dolt/view/commit_test.rb +0 -31
  53. data/test/dolt/view/gravatar_test.rb +0 -30
  54. data/test/dolt/view/markup_test.rb +0 -94
  55. data/test/dolt/view/multi_repository_test.rb +0 -35
  56. data/test/dolt/view/object_test.rb +0 -83
  57. data/test/dolt/view/single_repository_test.rb +0 -30
  58. data/test/dolt/view/smart_blob_renderer_test.rb +0 -38
  59. data/test/dolt/view/syntax_highlight_test.rb +0 -108
  60. data/test/dolt/view/tab_width_test.rb +0 -40
  61. data/test/dolt/view/tree_test.rb +0 -199
  62. data/views/500.erb +0 -22
  63. data/views/blame.erb +0 -42
  64. data/views/blob.erb +0 -31
  65. data/views/commits.erb +0 -26
  66. data/views/index.erb +0 -25
  67. data/views/layout.erb +0 -45
  68. data/views/raw.erb +0 -19
  69. data/views/refs.erb +0 -22
  70. data/views/tree.erb +0 -50
  71. data/views/tree_history.erb +0 -19
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- #--
3
- # Copyright (C) 2012 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 "dolt/view/smart_blob_renderer"
20
-
21
- describe Dolt::View::SmartBlobRenderer do
22
- include Dolt::View::Blob
23
- include Dolt::View::SmartBlobRenderer
24
-
25
- describe "#format_text_blob" do
26
- it "highlights a Ruby file" do
27
- html = format_text_blob("file.rb", "class File\n attr_reader :path\nend")
28
-
29
- assert_match "<span class=\"k\">class</span>", html
30
- assert_match "<span class=\"nc\">File</span>", html
31
- end
32
-
33
- it "wraps markup in .gts-markup" do
34
- html = render_markup("file.md", "# Hey")
35
- assert_match "<div class=\"gts-markup\">", html
36
- end
37
- end
38
- end
@@ -1,108 +0,0 @@
1
- # encoding: utf-8
2
- #--
3
- # Copyright (C) 2012 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 "dolt/view/single_repository"
20
- require "dolt/view/multi_repository"
21
- require "dolt/view/blob"
22
- require "dolt/view/syntax_highlight"
23
-
24
- describe Dolt::View::Blob do
25
- include Dolt::View::Blob
26
- include Dolt::View::SyntaxHighlight
27
-
28
- describe "#highlight" do
29
- it "highlights a Ruby file" do
30
- html = highlight("file.rb", "class File\n attr_reader :path\nend")
31
-
32
- assert_match "<span class=\"k\">class</span>", html
33
- assert_match "<span class=\"nc\">File</span>", html
34
- end
35
-
36
- it "highlights a YAML file" do
37
- html = highlight("file.yml", "something:\n is: true")
38
-
39
- assert_match "<span class=\"l-Scalar-Plain\">something</span>", html
40
- assert_match "<span class=\"p-Indicator\">:", html
41
- end
42
-
43
- it "highlights an .htm file" do
44
- html = highlight("file.htm", "<h1>Hey</h1>")
45
-
46
- assert_match "<span class=\"nt\">&lt;h1&gt;</span>", html
47
- assert_match "Hey<span class=\"nt\">&lt;/h1&gt;</span>", html
48
- end
49
-
50
- it "highlights file with custom suffix" do
51
- Dolt::View::SyntaxHighlight.add_lexer_alias("derp", "rb")
52
- html = highlight("file.derp", "class File")
53
-
54
- assert_match "<span class=\"k\">class</span>", html
55
- assert_match "<span class=\"nc\">File</span>", html
56
- end
57
-
58
- it "skips highlighting if lexer is missing" do
59
- html = highlight("file.trololol", "Yeah yeah yeah")
60
-
61
- assert_equal "Yeah yeah yeah", html
62
- end
63
- end
64
-
65
- describe "#format_blob" do
66
- it "highlights a Ruby file with line nums" do
67
- html = format_blob("file.rb", "class File\n attr_reader :path\nend")
68
-
69
- assert_match "<li class=\"L1\">", html
70
- assert_match "<span class=\"k\">class</span>", html
71
- end
72
-
73
- it "includes lexer as class name" do
74
- html = format_blob("file.rb", "class File\n attr_reader :path\nend")
75
-
76
- assert_match "rb", html
77
- end
78
- end
79
-
80
- describe "#lexer" do
81
- it "uses known suffix" do
82
- assert_equal "rb", lexer("file.rb")
83
- end
84
-
85
- it "uses registered suffix" do
86
- Dolt::View::SyntaxHighlight.add_lexer_alias("blarg", "blarg")
87
- assert_equal "blarg", lexer("file.blarg")
88
- end
89
-
90
- it "uses registered lexer" do
91
- Dolt::View::SyntaxHighlight.add_lexer_alias("bg", "blarg")
92
- assert_equal "blarg", lexer("file.bg")
93
- end
94
-
95
- it "uses known shebang" do
96
- assert_equal "rb", lexer("some-binary", "#!/usr/bin/env ruby\n")
97
- end
98
-
99
- it "uses registered shebang" do
100
- Dolt::View::SyntaxHighlight.add_lexer_shebang(/\bnode\b/, "js")
101
- assert_equal "js", lexer("some-binary", "#!/usr/bin/env node\n")
102
- end
103
-
104
- it "uses filename for unknown lexer" do
105
- assert_equal "some-binary", lexer("some-binary", "class Person\nend")
106
- end
107
- end
108
- end
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
- #--
3
- # Copyright (C) 2012 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 "dolt/view/tab_width"
20
-
21
- describe Dolt::View::TabWidth do
22
- include Dolt::View::Blob
23
- include Dolt::View::TabWidth
24
-
25
- describe "#format_whitespace" do
26
- it "limits width of whitespace" do
27
- Dolt::View::TabWidth.tab_width = 4
28
- html = format_whitespace("class File\n\tattr_reader :path\nend")
29
-
30
- assert_match(/ attr_reader/, html)
31
- end
32
-
33
- it "uses wide tabs in formatted blobs" do
34
- Dolt::View::TabWidth.tab_width = 12
35
- html = format_text_blob("file.rb", "class File\n\tattr_reader :path\nend")
36
-
37
- assert_match(/ attr_reader/, html)
38
- end
39
- end
40
- end
@@ -1,199 +0,0 @@
1
- # encoding: utf-8
2
- #--
3
- # Copyright (C) 2012 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 "dolt/view/single_repository"
20
- require "dolt/view/object"
21
- require "dolt/view/tree"
22
- require "ostruct"
23
-
24
- describe Dolt::View::Tree do
25
- include Dolt::Html
26
- include Dolt::View::SingleRepository
27
- include Dolt::View::Object
28
- include Dolt::View::Tree
29
-
30
- describe "#tree_entries" do
31
- before do
32
- async = { :name => "async", :type => :tree }
33
- disk_repo_resolver = { :type => :blob, :name => "disk_repo_resolver.rb" }
34
- git = { :type => :tree, :name => "git" }
35
- repo_actions = { :type => :blob, :name => "repo_actions.rb" }
36
- sinatra = { :type => :tree, :name => "sinatra" }
37
- template_renderer = { :type => :blob, :name => "template_renderer.rb" }
38
- version = { :type => :blob, :name => "version.rb" }
39
- view_rb = { :type => :blob, :name => "view.rb" }
40
- view = { :type => :tree, :name => "view" }
41
- @tree = OpenStruct.new({ :entries => [async, disk_repo_resolver, git,
42
- repo_actions, sinatra, template_renderer,
43
- version, view_rb, view] })
44
- end
45
-
46
- it "groups tree by type, dirs first" do
47
- entries = tree_entries(@tree)
48
-
49
- assert_equal :tree, entries[0][:type]
50
- assert_equal :tree, entries[1][:type]
51
- assert_equal :tree, entries[2][:type]
52
- assert_equal :tree, entries[3][:type]
53
- assert_equal :blob, entries[4][:type]
54
- assert_equal :blob, entries[5][:type]
55
- assert_equal :blob, entries[6][:type]
56
- assert_equal :blob, entries[7][:type]
57
- assert_equal :blob, entries[8][:type]
58
- end
59
-
60
- it "sorts by name" do
61
- entries = tree_entries(@tree)
62
-
63
- assert_equal "async", entries[0][:name]
64
- assert_equal "git", entries[1][:name]
65
- assert_equal "sinatra", entries[2][:name]
66
- assert_equal "view", entries[3][:name]
67
- assert_equal "disk_repo_resolver.rb", entries[4][:name]
68
- assert_equal "repo_actions.rb", entries[5][:name]
69
- assert_equal "template_renderer.rb", entries[6][:name]
70
- assert_equal "version.rb", entries[7][:name]
71
- assert_equal "view.rb", entries[8][:name]
72
- end
73
-
74
- it "lumps submodules in with directories" do
75
- async = { :name => "async", :type => :tree }
76
- disk_repo_resolver = { :type => :blob, :name => "disk_repo_resolver.rb" }
77
- git = { :type => :submodule, :name => "git" }
78
- tree = OpenStruct.new({ :entries => [async, disk_repo_resolver, git] })
79
- entries = tree_entries(tree)
80
-
81
- assert_equal :tree, entries[0][:type]
82
- assert_equal :submodule, entries[1][:type]
83
- assert_equal :blob, entries[2][:type]
84
- end
85
- end
86
-
87
- describe "#partition_path" do
88
- it "partitions root into double array" do
89
- parts = partition_path("")
90
- assert_equal [[""]], parts
91
-
92
- parts = partition_path("/")
93
- assert_equal [[""]], parts
94
-
95
- parts = partition_path("./")
96
- assert_equal [[""]], parts
97
- end
98
-
99
- it "partitions single directory" do
100
- parts = partition_path("lib")
101
- assert_equal [["", "lib"]], parts
102
- end
103
-
104
- it "partitions two directories" do
105
- parts = partition_path("lib/dolt")
106
- assert_equal [["", "lib"], ["dolt"]], parts
107
- end
108
-
109
- it "partitions multiple directories" do
110
- parts = partition_path("lib/dolt/git/help")
111
- assert_equal [["", "lib"], ["dolt"], ["git"], ["help"]], parts
112
- end
113
-
114
- it "ignore trailing slash" do
115
- parts = partition_path("lib/dolt/")
116
- assert_equal [["", "lib"], ["dolt"]], parts
117
- end
118
-
119
- it "chunks up leading path" do
120
- parts = partition_path("lib/dolt/very/deep", 3)
121
- assert_equal [["", "lib", "dolt"], ["very"], ["deep"]], parts
122
- end
123
-
124
- it "partitions short path with maxdepth" do
125
- parts = partition_path("lib", 3)
126
- assert_equal [["", "lib"]], parts
127
- end
128
- end
129
-
130
- describe "#accumulate_path" do
131
- it "accumulates partitioned path" do
132
- parts = accumulate_path(partition_path("lib/dolt/very/deep", 3))
133
- assert_equal [["", "lib", "lib/dolt"], ["lib/dolt/very"], ["lib/dolt/very/deep"]], parts
134
- end
135
- end
136
-
137
- describe "#tree_context" do
138
- def context(path, maxdepth = nil)
139
- tree_context("gitorious", "master", accumulate_path(partition_path(path, maxdepth)))
140
- end
141
-
142
- it "renders root as empty string" do
143
- assert_equal "", context("")
144
- assert_equal "", context("/")
145
- assert_equal "", context("./")
146
- end
147
-
148
- it "renders single path item as table row" do
149
- assert_equal 1, select(context("lib"), "tr").length
150
- assert_equal 1, select(context("./lib"), "tr").length
151
- end
152
-
153
- it "includes link to root in single table row" do
154
- assert_equal 2, select(context("lib"), "a").length
155
- end
156
-
157
- it "renders single path item in cell" do
158
- assert_equal 1, select(context("lib"), "td").length
159
- end
160
-
161
- it "renders single path item as link" do
162
- # Two, because there's always a link to the root directory
163
- assert_equal 2, select(context("lib"), "a").length
164
- assert_match /lib/, select(context("lib"), "a")[1]
165
- end
166
-
167
- it "renders single path item with open folder icon" do
168
- assert_match /icon-folder-open/, select(context("lib"), "i").first
169
- end
170
-
171
- it "renders two path items as two table rows" do
172
- assert_equal 2, select(context("lib/dolt"), "tr").length
173
- end
174
-
175
- it "renders two path items with colspan in first row" do
176
- assert_match /colspan="6"/, select(context("lib/dolt"), "tr").first
177
- assert_match /colspan="5"/, select(context("lib/dolt"), "tr")[1]
178
- tr = select(context("lib/dolt"), "tr")[1]
179
- assert_equal 2, select(tr, "td").length
180
- end
181
-
182
- it "renders condensed first entry with slashes" do
183
- links = select(context("src/phorkie/Database/Adapter", 3), "a")
184
-
185
- assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
186
- assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
187
- assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
188
- end
189
-
190
- it "renders long condensed first entry with slashes" do
191
- links = select(context("src/phorkie/Database/Adapter/Elasticsearch", 3), "a")
192
-
193
- assert_equal "<a href=\"/tree/master:\"><i class=\"icon icon-folder-open\"></i> /</a>", links.first
194
- assert_equal "<a href=\"/tree/master:src\"> src</a>", links[1]
195
- assert_equal "<a href=\"/tree/master:src/phorkie\">/ phorkie</a>", links[2]
196
- assert_equal "<a href=\"/tree/master:src/phorkie/Database\">/ Database</a>", links[3]
197
- end
198
- end
199
- end
@@ -1,22 +0,0 @@
1
- <%#
2
- # encoding: utf-8
3
- #--
4
- # Copyright (C) 2012 Gitorious AS
5
- #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU Affero General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU Affero General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Affero General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
- %>
20
- <h1><%= @title = "An error occurred" %></h1>
21
- <h2><%= error.respond_to?(:message) ? error.message : error %></h2>
22
- <p><a href="<%= tree_url(repository, ref, "") %>">Go back</a></p>
@@ -1,42 +0,0 @@
1
- <%#
2
- # encoding: utf-8
3
- #--
4
- # Copyright (C) 2012 Gitorious AS
5
- #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU Affero General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU Affero General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Affero General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
- %>
20
- <% @title = "Blame #{path} in #{repository}:master" %>
21
-
22
- <div class="gts-file gts-browser">
23
- <div id="gts-ref-selector-ph"></div>
24
- <ul class="pull-right gts-blob-view">
25
- <li><a href="<%= blob_url(repository, ref, path) %>">Blob content</a></li>
26
- <li class="active">Blame</li>
27
- <li><a href="<%= history_url(repository, ref, path) %>">History</a></li>
28
- <li><a href="<%= raw_url(repository, ref, path) %>">Raw blob</a></li>
29
- </ul>
30
- <%= breadcrumb(repository, ref, path) %>
31
- <table class="gts-code-listing">
32
- <% annotations = blame_annotations(blame) %>
33
- <% lines = blame_lines(path, blame) %>
34
- <% annotations.length.times do |i| %>
35
- <tr>
36
- <%= blame_annotation_cell(annotations[i]) %>
37
- <td class="linenum L<%= i + 1 %>"><%= i + 1 %></td>
38
- <%= blame_code_cell(lines[i]) %>
39
- </tr>
40
- <% end %>
41
- </table>
42
- </div>