dolt 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +21 -18
- data/Readme.md +3 -5
- data/bin/dolt +3 -6
- data/dolt.gemspec +5 -16
- data/lib/dolt/sinatra/multi_repo_browser.rb +3 -3
- data/lib/dolt/sinatra/single_repo_browser.rb +3 -3
- data/test/test_helper.rb +5 -3
- data/vendor/ui/css/gitorious.css +5 -0
- metadata +23 -239
- data/lib/dolt/async/when.rb +0 -128
- data/lib/dolt/disk_repo_resolver.rb +0 -39
- data/lib/dolt/git/blame.rb +0 -112
- data/lib/dolt/git/commit.rb +0 -73
- data/lib/dolt/git/repository.rb +0 -139
- data/lib/dolt/git/submodule.rb +0 -35
- data/lib/dolt/git/tree.rb +0 -42
- data/lib/dolt/repo_actions.rb +0 -91
- data/lib/dolt/template_renderer.rb +0 -67
- data/lib/dolt/version.rb +0 -21
- data/lib/dolt/view.rb +0 -23
- data/lib/dolt/view/binary_blob_embedder.rb +0 -41
- data/lib/dolt/view/blame.rb +0 -57
- data/lib/dolt/view/blob.rb +0 -97
- data/lib/dolt/view/breadcrumb.rb +0 -47
- data/lib/dolt/view/commit.rb +0 -27
- data/lib/dolt/view/gravatar.rb +0 -29
- data/lib/dolt/view/markup.rb +0 -107
- data/lib/dolt/view/multi_repository.rb +0 -27
- data/lib/dolt/view/object.rb +0 -44
- data/lib/dolt/view/single_repository.rb +0 -27
- data/lib/dolt/view/smart_blob_renderer.rb +0 -33
- data/lib/dolt/view/syntax_highlight.rb +0 -90
- data/lib/dolt/view/tab_width.rb +0 -30
- data/lib/dolt/view/tree.rb +0 -100
- data/test/dolt/async/when_test.rb +0 -112
- data/test/dolt/git/blame_test.rb +0 -128
- data/test/dolt/git/commit_test.rb +0 -89
- data/test/dolt/git/repository_test.rb +0 -186
- data/test/dolt/repo_actions_test.rb +0 -236
- data/test/dolt/template_renderer_test.rb +0 -122
- data/test/dolt/templates/blame_test.rb +0 -56
- data/test/dolt/templates/blob_test.rb +0 -118
- data/test/dolt/templates/commits_test.rb +0 -61
- data/test/dolt/templates/raw_test.rb +0 -41
- data/test/dolt/templates/refs_test.rb +0 -38
- data/test/dolt/templates/tree_history_test.rb +0 -93
- data/test/dolt/templates/tree_test.rb +0 -65
- data/test/dolt/view/binary_blob_embedder_test.rb +0 -49
- data/test/dolt/view/blame_test.rb +0 -122
- data/test/dolt/view/blob_test.rb +0 -116
- data/test/dolt/view/breadcrumb_test.rb +0 -46
- data/test/dolt/view/commit_test.rb +0 -31
- data/test/dolt/view/gravatar_test.rb +0 -30
- data/test/dolt/view/markup_test.rb +0 -94
- data/test/dolt/view/multi_repository_test.rb +0 -35
- data/test/dolt/view/object_test.rb +0 -83
- data/test/dolt/view/single_repository_test.rb +0 -30
- data/test/dolt/view/smart_blob_renderer_test.rb +0 -38
- data/test/dolt/view/syntax_highlight_test.rb +0 -108
- data/test/dolt/view/tab_width_test.rb +0 -40
- data/test/dolt/view/tree_test.rb +0 -199
- data/views/500.erb +0 -22
- data/views/blame.erb +0 -42
- data/views/blob.erb +0 -31
- data/views/commits.erb +0 -26
- data/views/index.erb +0 -25
- data/views/layout.erb +0 -45
- data/views/raw.erb +0 -19
- data/views/refs.erb +0 -22
- data/views/tree.erb +0 -50
- data/views/tree_history.erb +0 -19
data/lib/dolt/view/tree.rb
DELETED
@@ -1,100 +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
|
-
|
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
|
@@ -1,112 +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/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
|
data/test/dolt/git/blame_test.rb
DELETED
@@ -1,128 +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/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
|
@@ -1,89 +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/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
|
@@ -1,186 +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/git/repository"
|
20
|
-
require "time"
|
21
|
-
|
22
|
-
describe Dolt::Git::Repository do
|
23
|
-
include EM::MiniTest::Spec
|
24
|
-
before { @repository = Dolt::Git::Repository.new(".") }
|
25
|
-
|
26
|
-
describe "#submodules" do
|
27
|
-
it "returns deferrable" do
|
28
|
-
deferrable = @repository.submodules("master")
|
29
|
-
assert deferrable.respond_to?(:callback)
|
30
|
-
assert deferrable.respond_to?(:errback)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "yields list of submodules" do
|
34
|
-
@repository.submodules("c1f6cd9").callback do |submodules|
|
35
|
-
url = "git://gitorious.org/gitorious/ui3.git"
|
36
|
-
assert_equal [{ :path => "vendor/ui", :url => url }], submodules
|
37
|
-
done!
|
38
|
-
end
|
39
|
-
wait!
|
40
|
-
end
|
41
|
-
|
42
|
-
it "resolves with empty array if no submodules" do
|
43
|
-
@repository.submodules("26139a3").callback do |submodules|
|
44
|
-
assert_equal [], submodules
|
45
|
-
done!
|
46
|
-
end
|
47
|
-
wait!
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#tree" do
|
52
|
-
it "includes submodule data for trees" do
|
53
|
-
@repository.tree("3dc532f", "vendor").callback do |tree|
|
54
|
-
assert_equal({
|
55
|
-
:type => :submodule,
|
56
|
-
:filemode => 57344,
|
57
|
-
:name => "ui",
|
58
|
-
:oid => "d167e3e1c17a27e4cf459dd380670801b0659659",
|
59
|
-
:url => "git://gitorious.org/gitorious/ui3.git"
|
60
|
-
}, tree.entries.first)
|
61
|
-
done!
|
62
|
-
end
|
63
|
-
wait!
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#blame" do
|
68
|
-
it "returns deferrable" do
|
69
|
-
deferrable = @repository.blame("master", "Gemfile")
|
70
|
-
assert deferrable.respond_to?(:callback)
|
71
|
-
assert deferrable.respond_to?(:errback)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "yields blame" do
|
75
|
-
@repository.blame("master", "Gemfile").callback do |blame|
|
76
|
-
assert Dolt::Git::Blame === blame
|
77
|
-
done!
|
78
|
-
end
|
79
|
-
wait!
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#log" do
|
84
|
-
it "returns deferrable" do
|
85
|
-
deferrable = @repository.log("master", "Gemfile", 1)
|
86
|
-
assert deferrable.respond_to?(:callback)
|
87
|
-
assert deferrable.respond_to?(:errback)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "yields commits" do
|
91
|
-
@repository.log("master", "dolt.gemspec", 2).callback do |log|
|
92
|
-
assert_equal 2, log.length
|
93
|
-
assert Hash === log[0]
|
94
|
-
done!
|
95
|
-
end
|
96
|
-
wait!
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#tree_history" do
|
101
|
-
it "returns deferrable" do
|
102
|
-
deferrable = @repository.tree_history("master", "")
|
103
|
-
assert deferrable.respond_to?(:callback)
|
104
|
-
assert deferrable.respond_to?(:errback)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "fails if path is not a tree" do
|
108
|
-
deferrable = @repository.tree_history("master", "Gemfile")
|
109
|
-
deferrable.errback do |err|
|
110
|
-
assert_match /not a tree/, err.message
|
111
|
-
done!
|
112
|
-
end
|
113
|
-
wait!
|
114
|
-
end
|
115
|
-
|
116
|
-
it "fails if path does not exist in ref" do
|
117
|
-
deferrable = @repository.tree_history("26139a3", "test")
|
118
|
-
deferrable.errback do |err|
|
119
|
-
assert_match /does not exist/, err.message
|
120
|
-
done!
|
121
|
-
end
|
122
|
-
wait!
|
123
|
-
end
|
124
|
-
|
125
|
-
it "yields tree with history" do
|
126
|
-
promise = @repository.tree_history("48ffbf7", "")
|
127
|
-
|
128
|
-
promise.callback do |log|
|
129
|
-
assert_equal 11, log.length
|
130
|
-
expected = {
|
131
|
-
:type => :blob,
|
132
|
-
:oid => "e90021f89616ddf86855d05337c188408d3b417e",
|
133
|
-
:filemode => 33188,
|
134
|
-
:name => ".gitmodules",
|
135
|
-
:history => [{
|
136
|
-
:oid => "906d67b4f3e5de7364ba9b57d174d8998d53ced6",
|
137
|
-
:author => { :name => "Christian Johansen",
|
138
|
-
:email => "christian@cjohansen.no" },
|
139
|
-
:summary => "Working Moron server for viewing blobs",
|
140
|
-
:date => Time.parse("Mon Sep 10 15:07:39 +0200 2012"),
|
141
|
-
:message => ""
|
142
|
-
}]
|
143
|
-
}
|
144
|
-
|
145
|
-
assert_equal expected, log[0]
|
146
|
-
done!
|
147
|
-
end
|
148
|
-
|
149
|
-
promise.errback do |err|
|
150
|
-
puts "FAILED! #{err.inspect}"
|
151
|
-
end
|
152
|
-
|
153
|
-
wait!
|
154
|
-
end
|
155
|
-
|
156
|
-
it "yields nested tree with history" do
|
157
|
-
promise = @repository.tree_history("48ffbf7", "lib")
|
158
|
-
|
159
|
-
promise.callback do |log|
|
160
|
-
expected = [{
|
161
|
-
:type => :tree,
|
162
|
-
:oid => "58f84405b588699b24c619aa4cd83669c5623f88",
|
163
|
-
:filemode => 16384,
|
164
|
-
:name => "dolt",
|
165
|
-
:history => [{
|
166
|
-
:oid => "8ab4f8c42511f727244a02aeee04824891610bbd",
|
167
|
-
:author => { :name => "Christian Johansen",
|
168
|
-
:email => "christian@gitorious.com" },
|
169
|
-
:summary => "New version",
|
170
|
-
:date => Time.parse("Mon Oct 1 16:34:00 +0200 2012"),
|
171
|
-
:message => ""
|
172
|
-
}]
|
173
|
-
}]
|
174
|
-
|
175
|
-
assert_equal expected, log
|
176
|
-
done!
|
177
|
-
end
|
178
|
-
|
179
|
-
promise.errback do |err|
|
180
|
-
puts "FAILED! #{err.inspect}"
|
181
|
-
end
|
182
|
-
|
183
|
-
wait!
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|