libdolt 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +56 -0
- data/Rakefile +10 -0
- data/Readme.md +99 -0
- data/lib/libdolt/async/when.rb +128 -0
- data/lib/libdolt/disk_repo_resolver.rb +39 -0
- data/lib/libdolt/git/blame.rb +112 -0
- data/lib/libdolt/git/commit.rb +73 -0
- data/lib/libdolt/git/repository.rb +139 -0
- data/lib/libdolt/git/submodule.rb +35 -0
- data/lib/libdolt/git/tree.rb +42 -0
- data/lib/libdolt/repo_actions.rb +95 -0
- data/lib/libdolt/version.rb +21 -0
- data/lib/libdolt/view/binary_blob_embedder.rb +41 -0
- data/lib/libdolt/view/blame.rb +57 -0
- data/lib/libdolt/view/blob.rb +97 -0
- data/lib/libdolt/view/breadcrumb.rb +47 -0
- data/lib/libdolt/view/commit.rb +27 -0
- data/lib/libdolt/view/gravatar.rb +29 -0
- data/lib/libdolt/view/markup.rb +44 -0
- data/lib/libdolt/view/multi_repository.rb +27 -0
- data/lib/libdolt/view/object.rb +44 -0
- data/lib/libdolt/view/single_repository.rb +27 -0
- data/lib/libdolt/view/smart_blob_renderer.rb +33 -0
- data/lib/libdolt/view/syntax_highlight.rb +40 -0
- data/lib/libdolt/view/tab_width.rb +30 -0
- data/lib/libdolt/view/tree.rb +100 -0
- data/lib/libdolt/view.rb +23 -0
- data/lib/libdolt.rb +29 -0
- data/libdolt.gemspec +35 -0
- data/test/libdolt/async/when_test.rb +112 -0
- data/test/libdolt/git/blame_test.rb +128 -0
- data/test/libdolt/git/commit_test.rb +89 -0
- data/test/libdolt/git/repository_test.rb +186 -0
- data/test/libdolt/repo_actions_test.rb +236 -0
- data/test/libdolt/templates/blame_test.rb +54 -0
- data/test/libdolt/templates/blob_test.rb +116 -0
- data/test/libdolt/templates/commits_test.rb +59 -0
- data/test/libdolt/templates/raw_test.rb +39 -0
- data/test/libdolt/templates/refs_test.rb +36 -0
- data/test/libdolt/templates/tree_history_test.rb +91 -0
- data/test/libdolt/templates/tree_test.rb +63 -0
- data/test/libdolt/view/binary_blob_embedder_test.rb +49 -0
- data/test/libdolt/view/blame_test.rb +122 -0
- data/test/libdolt/view/blob_test.rb +116 -0
- data/test/libdolt/view/breadcrumb_test.rb +46 -0
- data/test/libdolt/view/commit_test.rb +31 -0
- data/test/libdolt/view/gravatar_test.rb +30 -0
- data/test/libdolt/view/markup_test.rb +70 -0
- data/test/libdolt/view/multi_repository_test.rb +35 -0
- data/test/libdolt/view/object_test.rb +83 -0
- data/test/libdolt/view/single_repository_test.rb +30 -0
- data/test/libdolt/view/smart_blob_renderer_test.rb +38 -0
- data/test/libdolt/view/syntax_highlight_test.rb +80 -0
- data/test/libdolt/view/tab_width_test.rb +40 -0
- data/test/libdolt/view/tree_test.rb +196 -0
- data/test/test_helper.rb +50 -0
- data/views/500.erb +22 -0
- data/views/blame.erb +42 -0
- data/views/blob.erb +31 -0
- data/views/commits.erb +26 -0
- data/views/index.erb +25 -0
- data/views/layout.erb +45 -0
- data/views/raw.erb +19 -0
- data/views/refs.erb +22 -0
- data/views/tree.erb +50 -0
- data/views/tree_history.erb +19 -0
- metadata +326 -0
@@ -0,0 +1,30 @@
|
|
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
|
+
|
19
|
+
module Dolt
|
20
|
+
module View
|
21
|
+
module TabWidth
|
22
|
+
def self.tab_width; @@tab_width; end
|
23
|
+
def self.tab_width=(tab_width); @@tab_width = tab_width; end
|
24
|
+
|
25
|
+
def format_whitespace(text)
|
26
|
+
text.gsub(/\t/, " " * TabWidth.tab_width)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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
|
+
|
19
|
+
module Dolt
|
20
|
+
module View
|
21
|
+
module Tree
|
22
|
+
def tree_url(repository, ref, path)
|
23
|
+
repo_url(repository, "/tree/#{ref}:#{path}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def tree_entries(tree)
|
27
|
+
sort(tree.entries.select { |e| [:tree, :submodule].index(e[:type]) }) +
|
28
|
+
sort(tree.entries.select { |e| e[:type] == :blob })
|
29
|
+
end
|
30
|
+
|
31
|
+
def tree_context(repo, ref, levels)
|
32
|
+
return "" if levels.length == 1 && levels[0].length == 1
|
33
|
+
total = 4 + levels.length
|
34
|
+
colspan = total
|
35
|
+
(levels.map do |level|
|
36
|
+
html = <<-HTML
|
37
|
+
<tr>
|
38
|
+
#{'<td></td>' * (total - colspan)}
|
39
|
+
<td colspan="#{colspan}">
|
40
|
+
#{tree_context_level_links(repo, ref, level)}
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
HTML
|
44
|
+
colspan -= 1
|
45
|
+
html
|
46
|
+
end).join
|
47
|
+
end
|
48
|
+
|
49
|
+
def tree_context_level_links(repo, ref, level)
|
50
|
+
extra = "<i class=\"icon icon-folder-open\"></i>"
|
51
|
+
|
52
|
+
(level.map do |path|
|
53
|
+
dir = File.dirname(path)
|
54
|
+
dir = "" if dir == "."
|
55
|
+
file = path == "" ? "/" : File.basename(path)
|
56
|
+
url = object_url(repo, ref, dir, { :type => :tree, :name => file })
|
57
|
+
html = "<a href=\"#{url}\">#{extra} #{file}</a>"
|
58
|
+
extra = extra == "" || extra == "/" ? "/" : ""
|
59
|
+
html
|
60
|
+
end).join(" ")
|
61
|
+
end
|
62
|
+
|
63
|
+
def partition_path(path, maxdepth = nil)
|
64
|
+
path = path.sub(/^\.?\//, "")
|
65
|
+
result = [[""]]
|
66
|
+
return result if path == ""
|
67
|
+
parts = path.split("/")
|
68
|
+
maxdepth ||= parts.length
|
69
|
+
fill_first = [parts.length, [1, parts.length - maxdepth + 1].max].min
|
70
|
+
fill_first.times { result[0] << parts.shift }
|
71
|
+
result << [parts.shift] while parts.length > 0
|
72
|
+
result
|
73
|
+
end
|
74
|
+
|
75
|
+
def accumulate_path(pieces)
|
76
|
+
acc = []
|
77
|
+
pieces.map do |piece|
|
78
|
+
piece.map do |p|
|
79
|
+
next p if p == ""
|
80
|
+
acc << p
|
81
|
+
File.join(acc)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def tree_table_padding_width(partitioned)
|
87
|
+
partitioned.length == 1 ? partitioned[0].length - 1 : partitioned.length
|
88
|
+
end
|
89
|
+
|
90
|
+
def tree_table_padding_td(partitioned)
|
91
|
+
"<td></td>" * tree_table_padding_width(partitioned)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def sort(entries)
|
96
|
+
entries.sort_by { |e| e[:name] }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/libdolt/view.rb
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
+
|
19
|
+
dir = File.join(File.dirname(__FILE__), "view")
|
20
|
+
|
21
|
+
Dir.entries(dir).select { |f| f =~ /\.rb$/ }.map do |file|
|
22
|
+
require(File.join(dir, file))
|
23
|
+
end
|
data/lib/libdolt.rb
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
+
require "libdolt/version"
|
21
|
+
require "libdolt/disk_repo_resolver"
|
22
|
+
require "libdolt/repo_actions"
|
23
|
+
require "libdolt/view"
|
24
|
+
|
25
|
+
module Dolt
|
26
|
+
def self.template_dir
|
27
|
+
File.join(File.dirname(__FILE__), "..", "views")
|
28
|
+
end
|
29
|
+
end
|
data/libdolt.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
3
|
+
require File.join(dir, "lib/libdolt/version")
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "libdolt"
|
7
|
+
s.version = Dolt::VERSION
|
8
|
+
s.authors = ["Christian Johansen"]
|
9
|
+
s.email = ["christian@gitorious.org"]
|
10
|
+
s.homepage = "http://gitorious.org/gitorious/libdolt"
|
11
|
+
s.summary = %q{Dolt API for serving git trees and syntax highlighted blobs}
|
12
|
+
s.description = %q{Dolt API for serving git trees and syntax highlighted blobs}
|
13
|
+
|
14
|
+
s.rubyforge_project = "libdolt"
|
15
|
+
|
16
|
+
s.add_dependency "eventmachine", "~>1.0"
|
17
|
+
s.add_dependency "em_pessimistic", "~>0.1"
|
18
|
+
s.add_dependency "em_rugged", "~> 0.1.2"
|
19
|
+
s.add_dependency "tzinfo", "~> 0.3"
|
20
|
+
s.add_dependency "makeup", "~>0"
|
21
|
+
s.add_dependency "htmlentities", "~> 4.3"
|
22
|
+
s.add_dependency "json", "~> 1.7"
|
23
|
+
s.add_dependency "mime-types", "~> 1.19"
|
24
|
+
|
25
|
+
s.add_development_dependency "minitest", "~> 2.0"
|
26
|
+
s.add_development_dependency "em-minitest-spec", "~> 1.1"
|
27
|
+
s.add_development_dependency "rake", "~> 0.9"
|
28
|
+
s.add_development_dependency "redcarpet"
|
29
|
+
s.add_development_dependency "tiltout", "~>1"
|
30
|
+
|
31
|
+
s.files = `git ls-files`.split("\n")
|
32
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
33
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
end
|
@@ -0,0 +1,112 @@
|
|
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 "libdolt/async/when"
|
20
|
+
|
21
|
+
describe When do
|
22
|
+
include EM::MiniTest::Spec
|
23
|
+
|
24
|
+
describe ".all" do
|
25
|
+
it "returns deferrable" do
|
26
|
+
d = When.all([When.deferred(42)])
|
27
|
+
assert d.respond_to?(:callback)
|
28
|
+
assert d.respond_to?(:errback)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "resolves immediately if no promises" do
|
32
|
+
d = When.all([])
|
33
|
+
d.callback do |results|
|
34
|
+
assert_equal [], results
|
35
|
+
done!
|
36
|
+
end
|
37
|
+
wait!
|
38
|
+
end
|
39
|
+
|
40
|
+
it "resolves when single deferrable resolves" do
|
41
|
+
deferred = When::Deferred.new
|
42
|
+
d = When.all([deferred.promise])
|
43
|
+
resolved = false
|
44
|
+
d.callback { |results| resolved = true }
|
45
|
+
|
46
|
+
assert !resolved
|
47
|
+
deferred.resolve(42)
|
48
|
+
assert resolved
|
49
|
+
end
|
50
|
+
|
51
|
+
it "resolves when all deferrables are resolved" do
|
52
|
+
deferreds = [When::Deferred.new, When::Deferred.new, When::Deferred.new]
|
53
|
+
d = When.all(deferreds.map(&:promise))
|
54
|
+
resolved = false
|
55
|
+
d.callback { |results| resolved = true }
|
56
|
+
|
57
|
+
assert !resolved
|
58
|
+
deferreds[0].resolve(42)
|
59
|
+
assert !resolved
|
60
|
+
deferreds[1].resolve(13)
|
61
|
+
assert !resolved
|
62
|
+
deferreds[2].resolve(3)
|
63
|
+
assert resolved
|
64
|
+
end
|
65
|
+
|
66
|
+
it "rejects when single deferrable rejects" do
|
67
|
+
deferred = When::Deferred.new
|
68
|
+
d = When.all([deferred.promise])
|
69
|
+
rejected = false
|
70
|
+
d.errback { |results| rejected = true }
|
71
|
+
|
72
|
+
assert !rejected
|
73
|
+
deferred.reject(StandardError.new)
|
74
|
+
assert rejected
|
75
|
+
end
|
76
|
+
|
77
|
+
it "rejects on first rejection" do
|
78
|
+
deferreds = [When::Deferred.new, When::Deferred.new, When::Deferred.new]
|
79
|
+
d = When.all(deferreds.map(&:promise))
|
80
|
+
rejected = false
|
81
|
+
d.errback { |results| rejected = true }
|
82
|
+
|
83
|
+
deferreds[0].resolve(42)
|
84
|
+
deferreds[2].reject(StandardError.new)
|
85
|
+
deferreds[1].resolve(13)
|
86
|
+
|
87
|
+
assert rejected
|
88
|
+
end
|
89
|
+
|
90
|
+
it "proxies resolution vaule in array" do
|
91
|
+
deferred = When::Deferred.new
|
92
|
+
d = When.all([deferred.promise])
|
93
|
+
results = nil
|
94
|
+
d.callback { |res| results = res }
|
95
|
+
|
96
|
+
deferred.resolve(42)
|
97
|
+
assert_equal [42], results
|
98
|
+
end
|
99
|
+
|
100
|
+
it "orders results like input" do
|
101
|
+
deferred1 = When::Deferred.new
|
102
|
+
deferred2 = When::Deferred.new
|
103
|
+
d = When.all([deferred1.promise, deferred2.promise])
|
104
|
+
results = nil
|
105
|
+
d.callback { |res| results = res }
|
106
|
+
|
107
|
+
deferred2.resolve(42)
|
108
|
+
deferred1.resolve(13)
|
109
|
+
assert_equal [13, 42], results
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,128 @@
|
|
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 "libdolt/git/blame"
|
20
|
+
|
21
|
+
describe Dolt::Git::Blame do
|
22
|
+
include EM::MiniTest::Spec
|
23
|
+
|
24
|
+
describe "parse" do
|
25
|
+
before do
|
26
|
+
@blame = <<-GIT
|
27
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 1 1 17
|
28
|
+
author Christian Johansen
|
29
|
+
author-mail <christian@cjohansen.no>
|
30
|
+
author-time 1347282459
|
31
|
+
author-tz +0200
|
32
|
+
committer Christian Johansen
|
33
|
+
committer-mail <christian@cjohansen.no>
|
34
|
+
committer-time 1347282459
|
35
|
+
committer-tz +0200
|
36
|
+
summary Working Moron server for viewing blobs
|
37
|
+
filename lib/moron/view.rb
|
38
|
+
# encoding: utf-8
|
39
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 2 2
|
40
|
+
#--
|
41
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 3 3
|
42
|
+
# Copyright (C) 2012 Gitorious AS
|
43
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 4 4
|
44
|
+
#
|
45
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 5 5
|
46
|
+
# This program is free software: you can redistribute it and/or modify
|
47
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 6 6
|
48
|
+
# it under the terms of the GNU Affero General Public License as published by
|
49
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 7 7
|
50
|
+
# the Free Software Foundation, either version 3 of the License, or
|
51
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 8 8
|
52
|
+
# (at your option) any later version.
|
53
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 9 9
|
54
|
+
#
|
55
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 10 10
|
56
|
+
# This program is distributed in the hope that it will be useful,
|
57
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 11 11
|
58
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
59
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 12 12
|
60
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
61
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 13 13
|
62
|
+
# GNU Affero General Public License for more details.
|
63
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 14 14
|
64
|
+
#
|
65
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 15 15
|
66
|
+
# You should have received a copy of the GNU Affero General Public License
|
67
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 16 16
|
68
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
69
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 17 17
|
70
|
+
#++
|
71
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 20 18 1
|
72
|
+
|
73
|
+
beb65bee5619c651532179b19421363ead2c2a44 19 19 1
|
74
|
+
author Christian Johansen
|
75
|
+
author-mail <christian@gitorious.com>
|
76
|
+
author-time 1348128947
|
77
|
+
author-tz +0200
|
78
|
+
committer Christian Johansen
|
79
|
+
committer-mail <christian@gitorious.com>
|
80
|
+
committer-time 1348128947
|
81
|
+
committer-tz +0200
|
82
|
+
summary Helpers are modules again
|
83
|
+
previous 05f0137175fe341545587a544315cd4a6cc2c824 lib/dolt/view.rb
|
84
|
+
filename lib/dolt/view.rb
|
85
|
+
dir = File.join(File.dirname(__FILE__), "view")
|
86
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 30 20 1
|
87
|
+
|
88
|
+
beb65bee5619c651532179b19421363ead2c2a44 21 21 2
|
89
|
+
Dir.entries(dir).select { |f| f =~ /\.rb$/ }.map do |file|
|
90
|
+
beb65bee5619c651532179b19421363ead2c2a44 22 22
|
91
|
+
require(File.join(dir, file))
|
92
|
+
906d67b4f3e5de7364ba9b57d174d8998d53ced6 58 23 1
|
93
|
+
end
|
94
|
+
GIT
|
95
|
+
|
96
|
+
@blame = Dolt::Git::Blame.parse_porcelain(@blame)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "has chunks" do
|
100
|
+
assert_equal 5, @blame.chunks.length
|
101
|
+
end
|
102
|
+
|
103
|
+
it "has chunk with commit meta data" do
|
104
|
+
chunk = @blame.chunks.first
|
105
|
+
author = chunk[:author]
|
106
|
+
committer = chunk[:committer]
|
107
|
+
|
108
|
+
assert_equal "906d67b4f3e5de7364ba9b57d174d8998d53ced6", chunk[:oid]
|
109
|
+
assert_equal "Christian Johansen", author[:name]
|
110
|
+
assert_equal "christian@cjohansen.no", author[:mail]
|
111
|
+
assert_equal "2012-09-10 17:07:39", author[:time].strftime("%Y-%m-%d %H:%M:%S")
|
112
|
+
assert_equal "Christian Johansen", committer[:name]
|
113
|
+
assert_equal "christian@cjohansen.no", committer[:mail]
|
114
|
+
assert_equal "2012-09-10 17:07:39", committer[:time].strftime("%Y-%m-%d %H:%M:%S")
|
115
|
+
assert_equal "Working Moron server for viewing blobs", chunk[:summary]
|
116
|
+
end
|
117
|
+
|
118
|
+
it "has chunk with lines" do
|
119
|
+
chunk = @blame.chunks.first
|
120
|
+
assert_equal 18, chunk[:lines].length
|
121
|
+
assert_equal "# Copyright (C) 2012 Gitorious AS", chunk[:lines][2]
|
122
|
+
end
|
123
|
+
|
124
|
+
it "repeats commit meta" do
|
125
|
+
assert_equal @blame.chunks[2][:committer], @blame.chunks[0][:committer]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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 "libdolt/git/commit"
|
20
|
+
|
21
|
+
describe Dolt::Git::Commit do
|
22
|
+
include EM::MiniTest::Spec
|
23
|
+
|
24
|
+
describe "parse" do
|
25
|
+
before do
|
26
|
+
@log = <<-GIT
|
27
|
+
commit dc0846b6c98a3f6db1172629329b70ada80598bb
|
28
|
+
Author: Christian Johansen <christian@gitorious.com>
|
29
|
+
Date: Thu Sep 20 15:55:52 2012 +0200
|
30
|
+
|
31
|
+
Add rough blame
|
32
|
+
|
33
|
+
commit 222eef3679553c9da2897144e03a5844f6e77586
|
34
|
+
Author: Christian Johansen <christian@gitorious.com>
|
35
|
+
Date: Wed Sep 19 12:27:54 2012 +0200
|
36
|
+
|
37
|
+
Rewrite template/views. Use EMRugged for Git.
|
38
|
+
|
39
|
+
- Not complete, still some failing tests
|
40
|
+
- View helpers need to change
|
41
|
+
|
42
|
+
commit 06293404488d9cc72e70eb2ae25aa609af73dada
|
43
|
+
Author: Christian Johansen <christian@gitorious.com>
|
44
|
+
Date: Tue Sep 11 20:03:14 2012 +0200
|
45
|
+
|
46
|
+
Rename FileSystemRepositoryResolver to DiskRepoResolver
|
47
|
+
|
48
|
+
commit 7a3d69a2327bb9575bb520fe30c6abb3bbd0b719
|
49
|
+
Author: Christian Johansen <christian@gitorious.com>
|
50
|
+
Date: Tue Sep 11 19:57:22 2012 +0200
|
51
|
+
|
52
|
+
One more rename: "Dolt" is shorter, better
|
53
|
+
|
54
|
+
commit eabcd577e921d01aeaf777d2daac565f88ab174c
|
55
|
+
Author: Christian Johansen <christian@gitorious.com>
|
56
|
+
Date: Tue Sep 11 15:25:50 2012 +0200
|
57
|
+
|
58
|
+
Moron was taken, going with Addlepate
|
59
|
+
|
60
|
+
GIT
|
61
|
+
|
62
|
+
@commits = Dolt::Git::Commit.parse_log(@log)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has commits" do
|
66
|
+
assert_equal 5, @commits.length
|
67
|
+
end
|
68
|
+
|
69
|
+
it "has commit oids" do
|
70
|
+
assert_equal "dc0846b6c98a3f6db1172629329b70ada80598bb", @commits[0][:oid]
|
71
|
+
assert_equal "222eef3679553c9da2897144e03a5844f6e77586", @commits[1][:oid]
|
72
|
+
assert_equal "06293404488d9cc72e70eb2ae25aa609af73dada", @commits[2][:oid]
|
73
|
+
assert_equal "7a3d69a2327bb9575bb520fe30c6abb3bbd0b719", @commits[3][:oid]
|
74
|
+
assert_equal "eabcd577e921d01aeaf777d2daac565f88ab174c", @commits[4][:oid]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "has author" do
|
78
|
+
expected = {
|
79
|
+
:name => "Christian Johansen",
|
80
|
+
:email => "christian@gitorious.com"
|
81
|
+
}
|
82
|
+
assert_equal expected, @commits.first[:author]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "has commit date" do
|
86
|
+
assert_equal "2012-09-11", @commits.last[:date].strftime("%Y-%m-%d")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|