dolt 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
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,61 +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/template_renderer"
20
- require "dolt/view"
21
-
22
- describe "commits template" do
23
- include Dolt::ViewTest
24
-
25
- def commit(num)
26
- { :oid => num + ("0" * 39),
27
- :summary => "Commit ##{num}",
28
- :author => @author,
29
- :date => Time.now }
30
- end
31
-
32
- before do
33
- @repo = "the-dolt"
34
- @author = {
35
- :name => "Christian Johansen",
36
- :email => "christian@gitorious.com"
37
- }
38
- @commit1 = commit("1")
39
- @commit2 = commit("2")
40
- @commit3 = commit("3")
41
- @template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
42
- end
43
-
44
- def render(path, commits, options = {})
45
- renderer = prepare_renderer(@template_root, options)
46
- renderer.render(:commits, {
47
- :commits => commits,
48
- :repository => @repo,
49
- :ref => options[:ref] || "master",
50
- :path => path
51
- })
52
- end
53
-
54
- it "renders history" do
55
- markup = render("app/models/repository.rb", [@commit1, @commit2, @commit3])
56
-
57
- assert_match /Commit #1/, markup
58
- assert_match /Commit #2/, markup
59
- assert_match /Commit #3/, markup
60
- end
61
- end
@@ -1,41 +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/template_renderer"
20
- require "dolt/view"
21
-
22
- class Blob
23
- attr_reader :content
24
- def initialize(content); @content = content; end
25
- end
26
-
27
- describe "raw template" do
28
- include Dolt::ViewTest
29
-
30
- before do
31
- @repo = "the-dolt"
32
- @template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
33
- end
34
-
35
- it "renders raw contents" do
36
- renderer = prepare_renderer(@template_root)
37
- html = renderer.render(:raw, { :blob => Blob.new("Something something") })
38
-
39
- assert_equal "Something something\n", html
40
- end
41
- end
@@ -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/template_renderer"
20
- require "dolt/view"
21
- require "json"
22
-
23
- describe "refs template" do
24
- include Dolt::ViewTest
25
-
26
- before do
27
- @repo = "the-dolt"
28
- @template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
29
- @renderer = prepare_renderer(@template_root)
30
- end
31
-
32
- it "renders JSON" do
33
- data = { "heads" => ["libgit2", "master"], "tags" => ["v2.1.0"] }
34
- html = @renderer.render(:refs, data)
35
-
36
- assert_equal data, JSON.parse(html)
37
- end
38
- end
@@ -1,93 +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/template_renderer"
20
- require "dolt/view"
21
- require "json"
22
-
23
- describe "tree_history template" do
24
- include Dolt::ViewTest
25
-
26
- before do
27
- @repo = "the-dolt"
28
- @template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
29
- @renderer = prepare_renderer(@template_root)
30
- @tree = [{
31
- :type => :blob,
32
- :oid => "e90021f89616ddf86855d05337c188408d3b417e",
33
- :filemode => 33188,
34
- :name => ".gitmodules",
35
- :history => [{
36
- :oid => "906d67b4f3e5de7364ba9b57d174d8998d53ced6",
37
- :author => { :name => "Christian Johansen",
38
- :email => "christian@cjohansen.no" },
39
- :summary => "Working Moron server for viewing blobs",
40
- :date => Time.parse("Mon Sep 10 15:07:39 +0200 2012"),
41
- :message => ""
42
- }]
43
- }, {
44
- :type => :blob,
45
- :oid => "c80ee3697054566d1a4247d80be78ec3ddfde295",
46
- :filemode => 33188,
47
- :name => "Gemfile",
48
- :history => [{
49
- :oid => "26139a3aba4aac8cbf658c0d0ea58b8983e4090b",
50
- :author => { :name => "Christian Johansen",
51
- :email => "christian@cjohansen.no" },
52
- :summary => "Initial commit",
53
- :date => Time.parse("Thu Aug 23 11:40:39 +0200 2012"),
54
- :message => ""
55
- }]
56
- }]
57
-
58
- @tree_array = [{
59
- "type" => "blob",
60
- "oid" => "e90021f89616ddf86855d05337c188408d3b417e",
61
- "filemode" => 33188,
62
- "name" => ".gitmodules",
63
- "history" => [{
64
- "oid" => "906d67b4f3e5de7364ba9b57d174d8998d53ced6",
65
- "author" => { "name" => "Christian Johansen",
66
- "email" => "christian@cjohansen.no" },
67
- "summary" => "Working Moron server for viewing blobs",
68
- "date" => "2012-09-10T15:07:39+02:00",
69
- "message" => ""
70
- }]
71
- }, {
72
- "type" => "blob",
73
- "oid" => "c80ee3697054566d1a4247d80be78ec3ddfde295",
74
- "filemode" => 33188,
75
- "name" => "Gemfile",
76
- "history" => [{
77
- "oid" => "26139a3aba4aac8cbf658c0d0ea58b8983e4090b",
78
- "author" => { "name" => "Christian Johansen",
79
- "email" => "christian@cjohansen.no" },
80
- "summary" => "Initial commit",
81
- "date" => "2012-08-23T11:40:39+02:00",
82
- "message" => ""
83
- }]
84
- }]
85
- end
86
-
87
- it "renders JSON" do
88
- data = { "tree" => @tree, "repository" => @repo, "ref" => "master", "path" => "" }
89
- json = @renderer.render(:tree_history, data)
90
-
91
- assert_equal @tree_array, JSON.parse(json)
92
- end
93
- end
@@ -1,65 +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/template_renderer"
20
- require "dolt/view"
21
-
22
- class Tree
23
- attr_reader :entries
24
- def initialize(entries); @entries = entries; end
25
- end
26
-
27
- describe "tree template" do
28
- include Dolt::ViewTest
29
-
30
- before do
31
- @repo = "the-dolt"
32
- @template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
33
- end
34
-
35
- def render(path, tree, options = {})
36
- renderer = prepare_renderer(@template_root, options)
37
- renderer.render(:tree, {
38
- :tree => tree,
39
- :repository => @repo,
40
- :ref => options[:ref] || "master",
41
- :path => path
42
- })
43
- end
44
-
45
- it "renders empty tree" do
46
- tree = Tree.new([])
47
- markup = render("app/models", tree)
48
-
49
- assert_match /<table class="table table-striped gts-tree-explorer"/, markup
50
- assert_match /data-gts-tree-history="/, markup
51
- end
52
-
53
- it "renders context for non-empty tree" do
54
- tree = Tree.new([
55
- { :type => :tree, :name => "lib" },
56
- { :type => :submodule, :name => "ui", :url => "git://git.git" },
57
- { :type => :blob, :name => "file.txt" }
58
- ])
59
-
60
- markup = render("app/models", tree)
61
-
62
- assert_match /icon-folder-open/, markup
63
- assert_match /tree\/master:app"/, markup
64
- end
65
- end
@@ -1,49 +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/blob"
21
- require "dolt/view/binary_blob_embedder"
22
-
23
- describe Dolt::View::BinaryBlobEmbedder do
24
- include Dolt::View::Blob
25
- include Dolt::View::BinaryBlobEmbedder
26
- include Dolt::View::SingleRepository
27
-
28
- it "renders image tag to view gif" do
29
- html = format_binary_blob("file.gif", "...", "gitorious", "master")
30
-
31
- assert_match /<img/, html
32
- assert_match /src="\/raw\/master:file.gif"/, html
33
- end
34
-
35
- it "renders image tag to view png" do
36
- html = format_binary_blob("file.png", "...", "gitorious", "master")
37
- assert_match /src="\/raw\/master:file.png"/, html
38
- end
39
-
40
- it "renders image tag to view jpg" do
41
- html = format_binary_blob("file.jpg", "...", "gitorious", "master")
42
- assert_match /src="\/raw\/master:file.jpg"/, html
43
- end
44
-
45
- it "renders image tag to view jpeg" do
46
- html = format_binary_blob("file.jpeg", "...", "gitorious", "master")
47
- assert_match /src="\/raw\/master:file.jpeg"/, html
48
- end
49
- end
@@ -1,122 +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/blame"
20
- require "ostruct"
21
-
22
- describe Dolt::View::Blame do
23
- include Dolt::Html
24
- include Dolt::View::Blame
25
-
26
- before do
27
- chunks = [{ :oid => "0000001", :lines => ["1", "2", "3"] },
28
- { :oid => "0000002", :lines => ["4", "5"] }]
29
- @blame = OpenStruct.new({ :chunks => chunks })
30
- end
31
-
32
- describe "#blame_annotations" do
33
- it "returns array of same length as total number of lines" do
34
- annotations = blame_annotations(@blame)
35
-
36
- assert_equal 5, annotations.length
37
- end
38
-
39
- it "stores annotation for first occurrence" do
40
- annotations = blame_annotations(@blame)
41
-
42
- assert_equal "0000001", annotations.first[:oid]
43
- end
44
-
45
- it "stores nil for consecutive entries in same chunk" do
46
- annotations = blame_annotations(@blame)
47
-
48
- assert_nil annotations[1]
49
- assert_nil annotations[2]
50
- refute_nil annotations[3]
51
- assert_nil annotations[4]
52
- end
53
- end
54
-
55
- describe "#blame_lines" do
56
- it "returns array of lines" do
57
- assert_equal 5, blame_lines("file.rb", @blame).length
58
- end
59
-
60
- it "does not modify lines" do
61
- assert_equal "1", blame_lines("file.rb", @blame).first
62
- end
63
- end
64
-
65
- describe "#blame_lines with #highlight" do
66
- def highlight(path, code)
67
- "{" + code.split("\n").map { |l| "#{path}:#{l}" }.join("\n") + "}"
68
- end
69
-
70
- it "highlights code before splitting" do
71
- lines = blame_lines("file.rb", @blame)
72
-
73
- assert_equal "{file.rb:1", lines.first
74
- assert_equal "file.rb:2", lines[1]
75
- assert_equal "file.rb:5}", lines.last
76
- end
77
- end
78
-
79
- describe "#blame_annotation_cell" do
80
- before do
81
- @oid = "1234567890" * 4
82
-
83
- @committer = {
84
- :name => "Christian Johansen",
85
- :time => Time.utc(2012, 1, 1, 12)
86
- }
87
- end
88
-
89
- it "returns table cell with annotated class" do
90
- html = blame_annotation_cell({ :committer => @committer, :oid => @oid })
91
-
92
- assert_match /gts-blame-annotation/, html
93
- assert_match /gts-annotated/, html
94
- assert_match /Christian Johansen/, html
95
- end
96
-
97
- it "includes the commit oid" do
98
- html = blame_annotation_cell({ :committer => @committer, :oid => @oid })
99
-
100
- assert_match /gts-sha/, html
101
- assert_match /1234567/, html
102
- refute_match /890/, html
103
- end
104
-
105
- it "includes the commit date" do
106
- html = blame_annotation_cell({ :committer => @committer, :oid => @oid })
107
-
108
- assert_match /2012-01-01/, html
109
- end
110
- end
111
-
112
- describe "#blame_code_cell" do
113
- it "returns table cell with code element" do
114
- html = blame_code_cell("var a = 42;")
115
-
116
- assert_equal 1, select(html, "td").length
117
- assert_match /gts-code/, html
118
- assert_equal 1, select(html, "code").length
119
- assert_match /a = 42/, html
120
- end
121
- end
122
- end