@@ -1,523 +1,526 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RepositoryGitTest < ActiveSupport::TestCase |
|
20 | class RepositoryGitTest < ActiveSupport::TestCase | |
21 | fixtures :projects, :repositories, :enabled_modules, :users, :roles |
|
21 | fixtures :projects, :repositories, :enabled_modules, :users, :roles | |
22 |
|
22 | |||
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s |
|
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
24 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
24 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
25 |
|
25 | |||
26 | NUM_REV = 28 |
|
26 | NUM_REV = 28 | |
27 | NUM_HEAD = 6 |
|
27 | NUM_HEAD = 6 | |
28 |
|
28 | |||
29 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
29 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
30 | CHAR_1_HEX = "\xc3\x9c" |
|
30 | CHAR_1_HEX = "\xc3\x9c" | |
31 |
|
31 | |||
32 | ## Ruby uses ANSI api to fork a process on Windows. |
|
32 | ## Ruby uses ANSI api to fork a process on Windows. | |
33 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
33 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
34 | ## and these are incompatible with ASCII. |
|
34 | ## and these are incompatible with ASCII. | |
35 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
35 | # WINDOWS_PASS = Redmine::Platform.mswin? | |
36 | WINDOWS_PASS = false |
|
36 | WINDOWS_PASS = false | |
37 |
|
37 | |||
38 | ## Git, Mercurial and CVS path encodings are binary. |
|
38 | ## Git, Mercurial and CVS path encodings are binary. | |
39 | ## Subversion supports URL encoding for path. |
|
39 | ## Subversion supports URL encoding for path. | |
40 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
40 | ## Redmine Mercurial adapter and extension use URL encoding. | |
41 | ## Git accepts only binary path in command line parameter. |
|
41 | ## Git accepts only binary path in command line parameter. | |
42 | ## So, there is no way to use binary command line parameter in JRuby. |
|
42 | ## So, there is no way to use binary command line parameter in JRuby. | |
43 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
43 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
44 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
44 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
45 |
|
45 | |||
46 | if File.directory?(REPOSITORY_PATH) |
|
46 | if File.directory?(REPOSITORY_PATH) | |
47 | def setup |
|
47 | def setup | |
48 | klass = Repository::Git |
|
48 | klass = Repository::Git | |
49 | assert_equal "Git", klass.scm_name |
|
49 | assert_equal "Git", klass.scm_name | |
50 | assert klass.scm_adapter_class |
|
50 | assert klass.scm_adapter_class | |
51 | assert_not_equal "", klass.scm_command |
|
51 | assert_not_equal "", klass.scm_command | |
52 | assert_equal true, klass.scm_available |
|
52 | assert_equal true, klass.scm_available | |
53 |
|
53 | |||
54 | @project = Project.find(3) |
|
54 | @project = Project.find(3) | |
55 | @repository = Repository::Git.create( |
|
55 | @repository = Repository::Git.create( | |
56 | :project => @project, |
|
56 | :project => @project, | |
57 | :url => REPOSITORY_PATH, |
|
57 | :url => REPOSITORY_PATH, | |
58 | :path_encoding => 'ISO-8859-1' |
|
58 | :path_encoding => 'ISO-8859-1' | |
59 | ) |
|
59 | ) | |
60 | assert @repository |
|
60 | assert @repository | |
61 | @char_1 = CHAR_1_HEX.dup |
|
61 | @char_1 = CHAR_1_HEX.dup | |
62 | if @char_1.respond_to?(:force_encoding) |
|
62 | if @char_1.respond_to?(:force_encoding) | |
63 | @char_1.force_encoding('UTF-8') |
|
63 | @char_1.force_encoding('UTF-8') | |
64 | end |
|
64 | end | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | def test_fetch_changesets_from_scratch |
|
67 | def test_fetch_changesets_from_scratch | |
68 | assert_nil @repository.extra_info |
|
68 | assert_nil @repository.extra_info | |
69 |
|
69 | |||
70 | assert_equal 0, @repository.changesets.count |
|
70 | assert_equal 0, @repository.changesets.count | |
71 | @repository.fetch_changesets |
|
71 | @repository.fetch_changesets | |
72 | @project.reload |
|
72 | @project.reload | |
73 |
|
73 | |||
74 | assert_equal NUM_REV, @repository.changesets.count |
|
74 | assert_equal NUM_REV, @repository.changesets.count | |
75 | assert_equal 39, @repository.changes.count |
|
75 | assert_equal 39, @repository.changes.count | |
76 |
|
76 | |||
77 | commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518") |
|
77 | commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518") | |
78 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
|
78 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid | |
79 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
|
79 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments | |
80 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
|
80 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer | |
81 | assert_equal User.find_by_login('jsmith'), commit.user |
|
81 | assert_equal User.find_by_login('jsmith'), commit.user | |
82 | # TODO: add a commit with commit time <> author time to the test repository |
|
82 | # TODO: add a commit with commit time <> author time to the test repository | |
83 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
83 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on | |
84 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
84 | assert_equal "2007-12-14".to_date, commit.commit_date | |
85 | assert_equal 3, commit.changes.count |
|
85 | assert_equal 3, commit.changes.count | |
86 | change = commit.changes.sort_by(&:path).first |
|
86 | change = commit.changes.sort_by(&:path).first | |
87 | assert_equal "README", change.path |
|
87 | assert_equal "README", change.path | |
88 | assert_equal "A", change.action |
|
88 | assert_equal "A", change.action | |
89 |
|
89 | |||
90 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size |
|
90 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size | |
91 | end |
|
91 | end | |
92 |
|
92 | |||
93 | def test_fetch_changesets_incremental |
|
93 | def test_fetch_changesets_incremental | |
94 | assert_equal 0, @repository.changesets.count |
|
94 | assert_equal 0, @repository.changesets.count | |
95 | @repository.fetch_changesets |
|
95 | @repository.fetch_changesets | |
96 | @project.reload |
|
96 | @project.reload | |
97 | assert_equal NUM_REV, @repository.changesets.count |
|
97 | assert_equal NUM_REV, @repository.changesets.count | |
98 | extra_info_heads = @repository.extra_info["heads"].dup |
|
98 | extra_info_heads = @repository.extra_info["heads"].dup | |
99 | assert_equal NUM_HEAD, extra_info_heads.size |
|
99 | assert_equal NUM_HEAD, extra_info_heads.size | |
100 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } |
|
100 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } | |
101 | assert_equal 4, extra_info_heads.size |
|
101 | assert_equal 4, extra_info_heads.size | |
102 |
|
102 | |||
103 | del_revs = [ |
|
103 | del_revs = [ | |
104 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
104 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
105 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
105 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
106 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
106 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
107 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
107 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
108 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
108 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
109 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
109 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
110 | ] |
|
110 | ] | |
111 | @repository.changesets.each do |rev| |
|
111 | @repository.changesets.each do |rev| | |
112 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
112 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
113 | end |
|
113 | end | |
114 | @project.reload |
|
114 | @project.reload | |
115 | cs1 = @repository.changesets |
|
115 | cs1 = @repository.changesets | |
116 | assert_equal NUM_REV - 6, cs1.count |
|
116 | assert_equal NUM_REV - 6, cs1.count | |
117 | extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" |
|
117 | extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" | |
118 | h = {} |
|
118 | h = {} | |
119 | h["heads"] = extra_info_heads |
|
119 | h["heads"] = extra_info_heads | |
120 | @repository.merge_extra_info(h) |
|
120 | @repository.merge_extra_info(h) | |
121 | @repository.save |
|
121 | @repository.save | |
122 | @project.reload |
|
122 | @project.reload | |
123 | assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8") |
|
123 | assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8") | |
124 | @repository.fetch_changesets |
|
124 | @repository.fetch_changesets | |
125 | @project.reload |
|
125 | @project.reload | |
126 | assert_equal NUM_REV, @repository.changesets.count |
|
126 | assert_equal NUM_REV, @repository.changesets.count | |
127 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size |
|
127 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size | |
128 | assert @repository.extra_info["heads"].index("83ca5fd546063a3c7dc2e568ba3355661a9e2b2c") |
|
128 | assert @repository.extra_info["heads"].index("83ca5fd546063a3c7dc2e568ba3355661a9e2b2c") | |
129 | end |
|
129 | end | |
130 |
|
130 | |||
131 | def test_fetch_changesets_history_editing |
|
131 | def test_fetch_changesets_history_editing | |
132 | assert_equal 0, @repository.changesets.count |
|
132 | assert_equal 0, @repository.changesets.count | |
133 | @repository.fetch_changesets |
|
133 | @repository.fetch_changesets | |
134 | @project.reload |
|
134 | @project.reload | |
135 | assert_equal NUM_REV, @repository.changesets.count |
|
135 | assert_equal NUM_REV, @repository.changesets.count | |
136 | extra_info_heads = @repository.extra_info["heads"].dup |
|
136 | extra_info_heads = @repository.extra_info["heads"].dup | |
137 | assert_equal NUM_HEAD, extra_info_heads.size |
|
137 | assert_equal NUM_HEAD, extra_info_heads.size | |
138 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } |
|
138 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } | |
139 | assert_equal 4, extra_info_heads.size |
|
139 | assert_equal 4, extra_info_heads.size | |
140 |
|
140 | |||
141 | del_revs = [ |
|
141 | del_revs = [ | |
142 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
142 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
143 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
143 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
144 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
144 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
145 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
145 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
146 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
146 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
147 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
147 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
148 | ] |
|
148 | ] | |
149 | @repository.changesets.each do |rev| |
|
149 | @repository.changesets.each do |rev| | |
150 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
150 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
151 | end |
|
151 | end | |
152 | @project.reload |
|
152 | @project.reload | |
153 | assert_equal NUM_REV - 6, @repository.changesets.count |
|
153 | assert_equal NUM_REV - 6, @repository.changesets.count | |
154 |
|
154 | |||
155 | c = Changeset.new(:repository => @repository, |
|
155 | c = Changeset.new(:repository => @repository, | |
156 | :committed_on => Time.now, |
|
156 | :committed_on => Time.now, | |
157 | :revision => "abcd1234efgh", |
|
157 | :revision => "abcd1234efgh", | |
158 | :scmid => "abcd1234efgh", |
|
158 | :scmid => "abcd1234efgh", | |
159 | :comments => 'test') |
|
159 | :comments => 'test') | |
160 | assert c.save |
|
160 | assert c.save | |
161 | @project.reload |
|
161 | @project.reload | |
162 | assert_equal NUM_REV - 5, @repository.changesets.count |
|
162 | assert_equal NUM_REV - 5, @repository.changesets.count | |
163 |
|
163 | |||
164 | extra_info_heads << "abcd1234efgh" |
|
164 | extra_info_heads << "abcd1234efgh" | |
165 | h = {} |
|
165 | h = {} | |
166 | h["heads"] = extra_info_heads |
|
166 | h["heads"] = extra_info_heads | |
167 | @repository.merge_extra_info(h) |
|
167 | @repository.merge_extra_info(h) | |
168 | @repository.save |
|
168 | @repository.save | |
169 | @project.reload |
|
169 | @project.reload | |
170 | h1 = @repository.extra_info["heads"].dup |
|
170 | h1 = @repository.extra_info["heads"].dup | |
171 | assert h1.index("abcd1234efgh") |
|
171 | assert h1.index("abcd1234efgh") | |
172 | assert_equal 5, h1.size |
|
172 | assert_equal 5, h1.size | |
173 |
|
173 | |||
174 | @repository.fetch_changesets |
|
174 | @repository.fetch_changesets | |
175 | @project.reload |
|
175 | @project.reload | |
176 | assert_equal NUM_REV - 5, @repository.changesets.count |
|
176 | assert_equal NUM_REV - 5, @repository.changesets.count | |
177 | h2 = @repository.extra_info["heads"].dup |
|
177 | h2 = @repository.extra_info["heads"].dup | |
178 | assert_equal h1, h2 |
|
178 | assert_equal h1, h2 | |
179 | end |
|
179 | end | |
180 |
|
180 | |||
181 | def test_parents |
|
181 | def test_parents | |
182 | assert_equal 0, @repository.changesets.count |
|
182 | assert_equal 0, @repository.changesets.count | |
183 | @repository.fetch_changesets |
|
183 | @repository.fetch_changesets | |
184 | @project.reload |
|
184 | @project.reload | |
185 | assert_equal NUM_REV, @repository.changesets.count |
|
185 | assert_equal NUM_REV, @repository.changesets.count | |
186 | r1 = @repository.find_changeset_by_name("7234cb2750b63") |
|
186 | r1 = @repository.find_changeset_by_name("7234cb2750b63") | |
187 | assert_equal [], r1.parents |
|
187 | assert_equal [], r1.parents | |
188 | r2 = @repository.find_changeset_by_name("899a15dba03a3") |
|
188 | r2 = @repository.find_changeset_by_name("899a15dba03a3") | |
189 | assert_equal 1, r2.parents.length |
|
189 | assert_equal 1, r2.parents.length | |
190 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
190 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", | |
191 | r2.parents[0].identifier |
|
191 | r2.parents[0].identifier | |
192 | r3 = @repository.find_changeset_by_name("32ae898b720c2") |
|
192 | r3 = @repository.find_changeset_by_name("32ae898b720c2") | |
193 | assert_equal 2, r3.parents.length |
|
193 | assert_equal 2, r3.parents.length | |
194 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort |
|
194 | r4 = [r3.parents[0].identifier, r3.parents[1].identifier].sort | |
195 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0] |
|
195 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", r4[0] | |
196 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1] |
|
196 | assert_equal "7e61ac704deecde634b51e59daa8110435dcb3da", r4[1] | |
197 | end |
|
197 | end | |
198 |
|
198 | |||
199 | def test_db_consistent_ordering_init |
|
199 | def test_db_consistent_ordering_init | |
200 | assert_nil @repository.extra_info |
|
200 | assert_nil @repository.extra_info | |
201 | assert_equal 0, @repository.changesets.count |
|
201 | assert_equal 0, @repository.changesets.count | |
202 | @repository.fetch_changesets |
|
202 | @repository.fetch_changesets | |
203 | @project.reload |
|
203 | @project.reload | |
204 | assert_equal 1, @repository.extra_info["db_consistent"]["ordering"] |
|
204 | assert_equal 1, @repository.extra_info["db_consistent"]["ordering"] | |
205 | end |
|
205 | end | |
206 |
|
206 | |||
207 | def test_db_consistent_ordering_before_1_2 |
|
207 | def test_db_consistent_ordering_before_1_2 | |
208 | assert_nil @repository.extra_info |
|
208 | assert_nil @repository.extra_info | |
209 | assert_equal 0, @repository.changesets.count |
|
209 | assert_equal 0, @repository.changesets.count | |
210 | @repository.fetch_changesets |
|
210 | @repository.fetch_changesets | |
211 | @project.reload |
|
211 | @project.reload | |
212 | assert_equal NUM_REV, @repository.changesets.count |
|
212 | assert_equal NUM_REV, @repository.changesets.count | |
213 | assert_not_nil @repository.extra_info |
|
213 | assert_not_nil @repository.extra_info | |
214 | @repository.write_attribute(:extra_info, nil) |
|
214 | h = {} | |
|
215 | h["heads"] = [] | |||
|
216 | h["branches"] = {} | |||
|
217 | h["db_consistent"] = {} | |||
|
218 | @repository.merge_extra_info(h) | |||
215 | @repository.save |
|
219 | @repository.save | |
216 | assert_nil @repository.extra_info |
|
|||
217 | assert_equal NUM_REV, @repository.changesets.count |
|
220 | assert_equal NUM_REV, @repository.changesets.count | |
218 | @repository.fetch_changesets |
|
221 | @repository.fetch_changesets | |
219 | @project.reload |
|
222 | @project.reload | |
220 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
223 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
221 |
|
224 | |||
222 | extra_info_heads = @repository.extra_info["heads"].dup |
|
225 | extra_info_heads = @repository.extra_info["heads"].dup | |
223 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } |
|
226 | extra_info_heads.delete_if { |x| x == "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c" } | |
224 | del_revs = [ |
|
227 | del_revs = [ | |
225 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
228 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
226 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
229 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
227 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
230 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
228 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
231 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
229 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
232 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
230 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
233 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
231 | ] |
|
234 | ] | |
232 | @repository.changesets.each do |rev| |
|
235 | @repository.changesets.each do |rev| | |
233 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
236 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
234 | end |
|
237 | end | |
235 | @project.reload |
|
238 | @project.reload | |
236 | cs1 = @repository.changesets |
|
239 | cs1 = @repository.changesets | |
237 | assert_equal NUM_REV - 6, cs1.count |
|
240 | assert_equal NUM_REV - 6, cs1.count | |
238 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
241 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
239 |
|
242 | |||
240 | extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" |
|
243 | extra_info_heads << "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" | |
241 | h = {} |
|
244 | h = {} | |
242 | h["heads"] = extra_info_heads |
|
245 | h["heads"] = extra_info_heads | |
243 | @repository.merge_extra_info(h) |
|
246 | @repository.merge_extra_info(h) | |
244 | @repository.save |
|
247 | @repository.save | |
245 | @project.reload |
|
248 | @project.reload | |
246 | assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8") |
|
249 | assert @repository.extra_info["heads"].index("4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8") | |
247 | @repository.fetch_changesets |
|
250 | @repository.fetch_changesets | |
248 | @project.reload |
|
251 | @project.reload | |
249 | assert_equal NUM_REV, @repository.changesets.count |
|
252 | assert_equal NUM_REV, @repository.changesets.count | |
250 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size |
|
253 | assert_equal NUM_HEAD, @repository.extra_info["heads"].size | |
251 |
|
254 | |||
252 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
255 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] | |
253 | end |
|
256 | end | |
254 |
|
257 | |||
255 | def test_heads_from_branches_hash |
|
258 | def test_heads_from_branches_hash | |
256 | assert_nil @repository.extra_info |
|
259 | assert_nil @repository.extra_info | |
257 | assert_equal 0, @repository.changesets.count |
|
260 | assert_equal 0, @repository.changesets.count | |
258 | assert_equal [], @repository.heads_from_branches_hash |
|
261 | assert_equal [], @repository.heads_from_branches_hash | |
259 | h = {} |
|
262 | h = {} | |
260 | h["branches"] = {} |
|
263 | h["branches"] = {} | |
261 | h["branches"]["test1"] = {} |
|
264 | h["branches"]["test1"] = {} | |
262 | h["branches"]["test1"]["last_scmid"] = "1234abcd" |
|
265 | h["branches"]["test1"]["last_scmid"] = "1234abcd" | |
263 | h["branches"]["test2"] = {} |
|
266 | h["branches"]["test2"] = {} | |
264 | h["branches"]["test2"]["last_scmid"] = "abcd1234" |
|
267 | h["branches"]["test2"]["last_scmid"] = "abcd1234" | |
265 | @repository.merge_extra_info(h) |
|
268 | @repository.merge_extra_info(h) | |
266 | @repository.save |
|
269 | @repository.save | |
267 | @project.reload |
|
270 | @project.reload | |
268 | assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort |
|
271 | assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort | |
269 | end |
|
272 | end | |
270 |
|
273 | |||
271 | def test_latest_changesets |
|
274 | def test_latest_changesets | |
272 | assert_equal 0, @repository.changesets.count |
|
275 | assert_equal 0, @repository.changesets.count | |
273 | @repository.fetch_changesets |
|
276 | @repository.fetch_changesets | |
274 | @project.reload |
|
277 | @project.reload | |
275 | assert_equal NUM_REV, @repository.changesets.count |
|
278 | assert_equal NUM_REV, @repository.changesets.count | |
276 | # with limit |
|
279 | # with limit | |
277 | changesets = @repository.latest_changesets('', 'master', 2) |
|
280 | changesets = @repository.latest_changesets('', 'master', 2) | |
278 | assert_equal 2, changesets.size |
|
281 | assert_equal 2, changesets.size | |
279 |
|
282 | |||
280 | # with path |
|
283 | # with path | |
281 | changesets = @repository.latest_changesets('images', 'master') |
|
284 | changesets = @repository.latest_changesets('images', 'master') | |
282 | assert_equal [ |
|
285 | assert_equal [ | |
283 | 'deff712f05a90d96edbd70facc47d944be5897e3', |
|
286 | 'deff712f05a90d96edbd70facc47d944be5897e3', | |
284 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
287 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
285 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
288 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
286 | ], changesets.collect(&:revision) |
|
289 | ], changesets.collect(&:revision) | |
287 |
|
290 | |||
288 | changesets = @repository.latest_changesets('README', nil) |
|
291 | changesets = @repository.latest_changesets('README', nil) | |
289 | assert_equal [ |
|
292 | assert_equal [ | |
290 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', |
|
293 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', | |
291 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', |
|
294 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', | |
292 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
295 | '713f4944648826f558cf548222f813dabe7cbb04', | |
293 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
296 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
294 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
297 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
295 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
298 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
296 | ], changesets.collect(&:revision) |
|
299 | ], changesets.collect(&:revision) | |
297 |
|
300 | |||
298 | # with path, revision and limit |
|
301 | # with path, revision and limit | |
299 | changesets = @repository.latest_changesets('images', '899a15dba') |
|
302 | changesets = @repository.latest_changesets('images', '899a15dba') | |
300 | assert_equal [ |
|
303 | assert_equal [ | |
301 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
304 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
302 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
305 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
303 | ], changesets.collect(&:revision) |
|
306 | ], changesets.collect(&:revision) | |
304 |
|
307 | |||
305 | changesets = @repository.latest_changesets('images', '899a15dba', 1) |
|
308 | changesets = @repository.latest_changesets('images', '899a15dba', 1) | |
306 | assert_equal [ |
|
309 | assert_equal [ | |
307 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
310 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
308 | ], changesets.collect(&:revision) |
|
311 | ], changesets.collect(&:revision) | |
309 |
|
312 | |||
310 | changesets = @repository.latest_changesets('README', '899a15dba') |
|
313 | changesets = @repository.latest_changesets('README', '899a15dba') | |
311 | assert_equal [ |
|
314 | assert_equal [ | |
312 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
315 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
313 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
316 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
314 | ], changesets.collect(&:revision) |
|
317 | ], changesets.collect(&:revision) | |
315 |
|
318 | |||
316 | changesets = @repository.latest_changesets('README', '899a15dba', 1) |
|
319 | changesets = @repository.latest_changesets('README', '899a15dba', 1) | |
317 | assert_equal [ |
|
320 | assert_equal [ | |
318 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
321 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
319 | ], changesets.collect(&:revision) |
|
322 | ], changesets.collect(&:revision) | |
320 |
|
323 | |||
321 | # with path, tag and limit |
|
324 | # with path, tag and limit | |
322 | changesets = @repository.latest_changesets('images', 'tag01.annotated') |
|
325 | changesets = @repository.latest_changesets('images', 'tag01.annotated') | |
323 | assert_equal [ |
|
326 | assert_equal [ | |
324 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
327 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
325 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
328 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
326 | ], changesets.collect(&:revision) |
|
329 | ], changesets.collect(&:revision) | |
327 |
|
330 | |||
328 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) |
|
331 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) | |
329 | assert_equal [ |
|
332 | assert_equal [ | |
330 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
333 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
331 | ], changesets.collect(&:revision) |
|
334 | ], changesets.collect(&:revision) | |
332 |
|
335 | |||
333 | changesets = @repository.latest_changesets('README', 'tag01.annotated') |
|
336 | changesets = @repository.latest_changesets('README', 'tag01.annotated') | |
334 | assert_equal [ |
|
337 | assert_equal [ | |
335 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
338 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
336 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
339 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
337 | ], changesets.collect(&:revision) |
|
340 | ], changesets.collect(&:revision) | |
338 |
|
341 | |||
339 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) |
|
342 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) | |
340 | assert_equal [ |
|
343 | assert_equal [ | |
341 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
344 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
342 | ], changesets.collect(&:revision) |
|
345 | ], changesets.collect(&:revision) | |
343 |
|
346 | |||
344 | # with path, branch and limit |
|
347 | # with path, branch and limit | |
345 | changesets = @repository.latest_changesets('images', 'test_branch') |
|
348 | changesets = @repository.latest_changesets('images', 'test_branch') | |
346 | assert_equal [ |
|
349 | assert_equal [ | |
347 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
350 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
348 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
351 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
349 | ], changesets.collect(&:revision) |
|
352 | ], changesets.collect(&:revision) | |
350 |
|
353 | |||
351 | changesets = @repository.latest_changesets('images', 'test_branch', 1) |
|
354 | changesets = @repository.latest_changesets('images', 'test_branch', 1) | |
352 | assert_equal [ |
|
355 | assert_equal [ | |
353 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
356 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
354 | ], changesets.collect(&:revision) |
|
357 | ], changesets.collect(&:revision) | |
355 |
|
358 | |||
356 | changesets = @repository.latest_changesets('README', 'test_branch') |
|
359 | changesets = @repository.latest_changesets('README', 'test_branch') | |
357 | assert_equal [ |
|
360 | assert_equal [ | |
358 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
361 | '713f4944648826f558cf548222f813dabe7cbb04', | |
359 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
362 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
360 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
363 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
361 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
364 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
362 | ], changesets.collect(&:revision) |
|
365 | ], changesets.collect(&:revision) | |
363 |
|
366 | |||
364 | changesets = @repository.latest_changesets('README', 'test_branch', 2) |
|
367 | changesets = @repository.latest_changesets('README', 'test_branch', 2) | |
365 | assert_equal [ |
|
368 | assert_equal [ | |
366 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
369 | '713f4944648826f558cf548222f813dabe7cbb04', | |
367 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
370 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
368 | ], changesets.collect(&:revision) |
|
371 | ], changesets.collect(&:revision) | |
369 |
|
372 | |||
370 | if JRUBY_SKIP |
|
373 | if JRUBY_SKIP | |
371 | puts JRUBY_SKIP_STR |
|
374 | puts JRUBY_SKIP_STR | |
372 | else |
|
375 | else | |
373 | # latin-1 encoding path |
|
376 | # latin-1 encoding path | |
374 | changesets = @repository.latest_changesets( |
|
377 | changesets = @repository.latest_changesets( | |
375 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') |
|
378 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') | |
376 | assert_equal [ |
|
379 | assert_equal [ | |
377 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
380 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
378 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', |
|
381 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', | |
379 | ], changesets.collect(&:revision) |
|
382 | ], changesets.collect(&:revision) | |
380 |
|
383 | |||
381 | changesets = @repository.latest_changesets( |
|
384 | changesets = @repository.latest_changesets( | |
382 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) |
|
385 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) | |
383 | assert_equal [ |
|
386 | assert_equal [ | |
384 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
387 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
385 | ], changesets.collect(&:revision) |
|
388 | ], changesets.collect(&:revision) | |
386 | end |
|
389 | end | |
387 | end |
|
390 | end | |
388 |
|
391 | |||
389 | def test_latest_changesets_latin_1_dir |
|
392 | def test_latest_changesets_latin_1_dir | |
390 | if WINDOWS_PASS |
|
393 | if WINDOWS_PASS | |
391 | # |
|
394 | # | |
392 | elsif JRUBY_SKIP |
|
395 | elsif JRUBY_SKIP | |
393 | puts JRUBY_SKIP_STR |
|
396 | puts JRUBY_SKIP_STR | |
394 | else |
|
397 | else | |
395 | assert_equal 0, @repository.changesets.count |
|
398 | assert_equal 0, @repository.changesets.count | |
396 | @repository.fetch_changesets |
|
399 | @repository.fetch_changesets | |
397 | @project.reload |
|
400 | @project.reload | |
398 | assert_equal NUM_REV, @repository.changesets.count |
|
401 | assert_equal NUM_REV, @repository.changesets.count | |
399 | changesets = @repository.latest_changesets( |
|
402 | changesets = @repository.latest_changesets( | |
400 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') |
|
403 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') | |
401 | assert_equal [ |
|
404 | assert_equal [ | |
402 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', |
|
405 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', | |
403 | ], changesets.collect(&:revision) |
|
406 | ], changesets.collect(&:revision) | |
404 | end |
|
407 | end | |
405 | end |
|
408 | end | |
406 |
|
409 | |||
407 | def test_find_changeset_by_name |
|
410 | def test_find_changeset_by_name | |
408 | assert_equal 0, @repository.changesets.count |
|
411 | assert_equal 0, @repository.changesets.count | |
409 | @repository.fetch_changesets |
|
412 | @repository.fetch_changesets | |
410 | @project.reload |
|
413 | @project.reload | |
411 | assert_equal NUM_REV, @repository.changesets.count |
|
414 | assert_equal NUM_REV, @repository.changesets.count | |
412 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| |
|
415 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| | |
413 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
416 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
414 | @repository.find_changeset_by_name(r).revision |
|
417 | @repository.find_changeset_by_name(r).revision | |
415 | end |
|
418 | end | |
416 | end |
|
419 | end | |
417 |
|
420 | |||
418 | def test_find_changeset_by_empty_name |
|
421 | def test_find_changeset_by_empty_name | |
419 | assert_equal 0, @repository.changesets.count |
|
422 | assert_equal 0, @repository.changesets.count | |
420 | @repository.fetch_changesets |
|
423 | @repository.fetch_changesets | |
421 | @project.reload |
|
424 | @project.reload | |
422 | assert_equal NUM_REV, @repository.changesets.count |
|
425 | assert_equal NUM_REV, @repository.changesets.count | |
423 | ['', ' ', nil].each do |r| |
|
426 | ['', ' ', nil].each do |r| | |
424 | assert_nil @repository.find_changeset_by_name(r) |
|
427 | assert_nil @repository.find_changeset_by_name(r) | |
425 | end |
|
428 | end | |
426 | end |
|
429 | end | |
427 |
|
430 | |||
428 | def test_identifier |
|
431 | def test_identifier | |
429 | assert_equal 0, @repository.changesets.count |
|
432 | assert_equal 0, @repository.changesets.count | |
430 | @repository.fetch_changesets |
|
433 | @repository.fetch_changesets | |
431 | @project.reload |
|
434 | @project.reload | |
432 | assert_equal NUM_REV, @repository.changesets.count |
|
435 | assert_equal NUM_REV, @repository.changesets.count | |
433 | c = @repository.changesets.find_by_revision( |
|
436 | c = @repository.changesets.find_by_revision( | |
434 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
437 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
435 | assert_equal c.scmid, c.identifier |
|
438 | assert_equal c.scmid, c.identifier | |
436 | end |
|
439 | end | |
437 |
|
440 | |||
438 | def test_format_identifier |
|
441 | def test_format_identifier | |
439 | assert_equal 0, @repository.changesets.count |
|
442 | assert_equal 0, @repository.changesets.count | |
440 | @repository.fetch_changesets |
|
443 | @repository.fetch_changesets | |
441 | @project.reload |
|
444 | @project.reload | |
442 | assert_equal NUM_REV, @repository.changesets.count |
|
445 | assert_equal NUM_REV, @repository.changesets.count | |
443 | c = @repository.changesets.find_by_revision( |
|
446 | c = @repository.changesets.find_by_revision( | |
444 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
447 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
445 | assert_equal '7234cb27', c.format_identifier |
|
448 | assert_equal '7234cb27', c.format_identifier | |
446 | end |
|
449 | end | |
447 |
|
450 | |||
448 | def test_activities |
|
451 | def test_activities | |
449 | c = Changeset.new(:repository => @repository, |
|
452 | c = Changeset.new(:repository => @repository, | |
450 | :committed_on => Time.now, |
|
453 | :committed_on => Time.now, | |
451 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
454 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
452 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
455 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
453 | :comments => 'test') |
|
456 | :comments => 'test') | |
454 | assert c.event_title.include?('abc7234c:') |
|
457 | assert c.event_title.include?('abc7234c:') | |
455 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] |
|
458 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] | |
456 | end |
|
459 | end | |
457 |
|
460 | |||
458 | def test_log_utf8 |
|
461 | def test_log_utf8 | |
459 | assert_equal 0, @repository.changesets.count |
|
462 | assert_equal 0, @repository.changesets.count | |
460 | @repository.fetch_changesets |
|
463 | @repository.fetch_changesets | |
461 | @project.reload |
|
464 | @project.reload | |
462 | assert_equal NUM_REV, @repository.changesets.count |
|
465 | assert_equal NUM_REV, @repository.changesets.count | |
463 | str_felix_hex = FELIX_HEX.dup |
|
466 | str_felix_hex = FELIX_HEX.dup | |
464 | if str_felix_hex.respond_to?(:force_encoding) |
|
467 | if str_felix_hex.respond_to?(:force_encoding) | |
465 | str_felix_hex.force_encoding('UTF-8') |
|
468 | str_felix_hex.force_encoding('UTF-8') | |
466 | end |
|
469 | end | |
467 | c = @repository.changesets.find_by_revision( |
|
470 | c = @repository.changesets.find_by_revision( | |
468 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') |
|
471 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |
469 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer |
|
472 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer | |
470 | end |
|
473 | end | |
471 |
|
474 | |||
472 | def test_previous |
|
475 | def test_previous | |
473 | assert_equal 0, @repository.changesets.count |
|
476 | assert_equal 0, @repository.changesets.count | |
474 | @repository.fetch_changesets |
|
477 | @repository.fetch_changesets | |
475 | @project.reload |
|
478 | @project.reload | |
476 | assert_equal NUM_REV, @repository.changesets.count |
|
479 | assert_equal NUM_REV, @repository.changesets.count | |
477 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
480 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
478 | changeset = @repository.find_changeset_by_name(r1) |
|
481 | changeset = @repository.find_changeset_by_name(r1) | |
479 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
482 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
480 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
483 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous | |
481 | end |
|
484 | end | |
482 | end |
|
485 | end | |
483 | end |
|
486 | end | |
484 |
|
487 | |||
485 | def test_previous_nil |
|
488 | def test_previous_nil | |
486 | assert_equal 0, @repository.changesets.count |
|
489 | assert_equal 0, @repository.changesets.count | |
487 | @repository.fetch_changesets |
|
490 | @repository.fetch_changesets | |
488 | @project.reload |
|
491 | @project.reload | |
489 | assert_equal NUM_REV, @repository.changesets.count |
|
492 | assert_equal NUM_REV, @repository.changesets.count | |
490 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb275|.each do |r1| |
|
493 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb275|.each do |r1| | |
491 | changeset = @repository.find_changeset_by_name(r1) |
|
494 | changeset = @repository.find_changeset_by_name(r1) | |
492 | assert_nil changeset.previous |
|
495 | assert_nil changeset.previous | |
493 | end |
|
496 | end | |
494 | end |
|
497 | end | |
495 |
|
498 | |||
496 | def test_next |
|
499 | def test_next | |
497 | assert_equal 0, @repository.changesets.count |
|
500 | assert_equal 0, @repository.changesets.count | |
498 | @repository.fetch_changesets |
|
501 | @repository.fetch_changesets | |
499 | @project.reload |
|
502 | @project.reload | |
500 | assert_equal NUM_REV, @repository.changesets.count |
|
503 | assert_equal NUM_REV, @repository.changesets.count | |
501 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
504 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
502 | changeset = @repository.find_changeset_by_name(r2) |
|
505 | changeset = @repository.find_changeset_by_name(r2) | |
503 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
506 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
504 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
507 | assert_equal @repository.find_changeset_by_name(r1), changeset.next | |
505 | end |
|
508 | end | |
506 | end |
|
509 | end | |
507 | end |
|
510 | end | |
508 |
|
511 | |||
509 | def test_next_nil |
|
512 | def test_next_nil | |
510 | assert_equal 0, @repository.changesets.count |
|
513 | assert_equal 0, @repository.changesets.count | |
511 | @repository.fetch_changesets |
|
514 | @repository.fetch_changesets | |
512 | @project.reload |
|
515 | @project.reload | |
513 | assert_equal NUM_REV, @repository.changesets.count |
|
516 | assert_equal NUM_REV, @repository.changesets.count | |
514 | %w|2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 2a682156a3b6e77a|.each do |r1| |
|
517 | %w|2a682156a3b6e77a8bf9cd4590e8db757f3c6c78 2a682156a3b6e77a|.each do |r1| | |
515 | changeset = @repository.find_changeset_by_name(r1) |
|
518 | changeset = @repository.find_changeset_by_name(r1) | |
516 | assert_nil changeset.next |
|
519 | assert_nil changeset.next | |
517 | end |
|
520 | end | |
518 | end |
|
521 | end | |
519 | else |
|
522 | else | |
520 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
523 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" | |
521 | def test_fake; assert true end |
|
524 | def test_fake; assert true end | |
522 | end |
|
525 | end | |
523 | end |
|
526 | end |
General Comments 0
You need to be logged in to leave comments.
Login now