@@ -1,347 +1,387 | |||||
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 | # No '..' in the repository path |
|
23 | # No '..' in the repository path | |
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' | |
25 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
25 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
26 |
|
26 | |||
27 | FELIX_HEX = "Felix Sch\xC3\xA4fer" |
|
27 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
28 | CHAR_1_HEX = "\xc3\x9c" |
|
28 | CHAR_1_HEX = "\xc3\x9c" | |
29 |
|
29 | |||
30 | ## Ruby uses ANSI api to fork a process on Windows. |
|
30 | ## Ruby uses ANSI api to fork a process on Windows. | |
31 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
31 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
32 | ## and these are incompatible with ASCII. |
|
32 | ## and these are incompatible with ASCII. | |
33 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
33 | # WINDOWS_PASS = Redmine::Platform.mswin? | |
34 | WINDOWS_PASS = false |
|
34 | WINDOWS_PASS = false | |
35 |
|
35 | |||
36 | if File.directory?(REPOSITORY_PATH) |
|
36 | if File.directory?(REPOSITORY_PATH) | |
37 | def setup |
|
37 | def setup | |
38 | klass = Repository::Git |
|
38 | klass = Repository::Git | |
39 | assert_equal "Git", klass.scm_name |
|
39 | assert_equal "Git", klass.scm_name | |
40 | assert klass.scm_adapter_class |
|
40 | assert klass.scm_adapter_class | |
41 | assert_not_equal "", klass.scm_command |
|
41 | assert_not_equal "", klass.scm_command | |
42 | assert_equal true, klass.scm_available |
|
42 | assert_equal true, klass.scm_available | |
43 |
|
43 | |||
44 | @project = Project.find(3) |
|
44 | @project = Project.find(3) | |
45 | @repository = Repository::Git.create( |
|
45 | @repository = Repository::Git.create( | |
46 | :project => @project, |
|
46 | :project => @project, | |
47 | :url => REPOSITORY_PATH, |
|
47 | :url => REPOSITORY_PATH, | |
48 | :path_encoding => 'ISO-8859-1' |
|
48 | :path_encoding => 'ISO-8859-1' | |
49 | ) |
|
49 | ) | |
50 | assert @repository |
|
50 | assert @repository | |
51 | @char_1 = CHAR_1_HEX.dup |
|
51 | @char_1 = CHAR_1_HEX.dup | |
52 | if @char_1.respond_to?(:force_encoding) |
|
52 | if @char_1.respond_to?(:force_encoding) | |
53 | @char_1.force_encoding('UTF-8') |
|
53 | @char_1.force_encoding('UTF-8') | |
54 | end |
|
54 | end | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_fetch_changesets_from_scratch |
|
57 | def test_fetch_changesets_from_scratch | |
58 | assert_nil @repository.extra_info |
|
58 | assert_nil @repository.extra_info | |
59 |
|
59 | |||
60 | @repository.fetch_changesets |
|
60 | @repository.fetch_changesets | |
61 | @repository.reload |
|
61 | @repository.reload | |
62 |
|
62 | |||
63 | assert_equal 21, @repository.changesets.count |
|
63 | assert_equal 21, @repository.changesets.count | |
64 | assert_equal 33, @repository.changes.count |
|
64 | assert_equal 33, @repository.changes.count | |
65 |
|
65 | |||
66 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') |
|
66 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') | |
67 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
|
67 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments | |
68 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
|
68 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer | |
69 | assert_equal User.find_by_login('jsmith'), commit.user |
|
69 | assert_equal User.find_by_login('jsmith'), commit.user | |
70 | # TODO: add a commit with commit time <> author time to the test repository |
|
70 | # TODO: add a commit with commit time <> author time to the test repository | |
71 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
71 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on | |
72 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
72 | assert_equal "2007-12-14".to_date, commit.commit_date | |
73 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision |
|
73 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision | |
74 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
|
74 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid | |
75 | assert_equal 3, commit.changes.count |
|
75 | assert_equal 3, commit.changes.count | |
76 | change = commit.changes.sort_by(&:path).first |
|
76 | change = commit.changes.sort_by(&:path).first | |
77 | assert_equal "README", change.path |
|
77 | assert_equal "README", change.path | |
78 | assert_equal "A", change.action |
|
78 | assert_equal "A", change.action | |
79 |
|
79 | |||
80 | assert_equal 4, @repository.extra_info["branches"].size |
|
80 | assert_equal 4, @repository.extra_info["branches"].size | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | def test_fetch_changesets_incremental |
|
83 | def test_fetch_changesets_incremental | |
84 | @repository.fetch_changesets |
|
84 | @repository.fetch_changesets | |
85 | @repository.reload |
|
85 | @repository.reload | |
86 | assert_equal 21, @repository.changesets.count |
|
86 | assert_equal 21, @repository.changesets.count | |
87 | assert_equal 33, @repository.changes.count |
|
87 | assert_equal 33, @repository.changes.count | |
88 | extra_info_db = @repository.extra_info["branches"] |
|
88 | extra_info_db = @repository.extra_info["branches"] | |
89 | assert_equal 4, extra_info_db.size |
|
89 | assert_equal 4, extra_info_db.size | |
90 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", |
|
90 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", | |
91 | extra_info_db["latin-1-path-encoding"]["last_scmid"] |
|
91 | extra_info_db["latin-1-path-encoding"]["last_scmid"] | |
92 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
92 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
93 | extra_info_db["master"]["last_scmid"] |
|
93 | extra_info_db["master"]["last_scmid"] | |
94 |
|
94 | |||
95 | del_revs = [ |
|
95 | del_revs = [ | |
96 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", |
|
96 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |
97 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", |
|
97 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |
98 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", |
|
98 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |
99 | "deff712f05a90d96edbd70facc47d944be5897e3", |
|
99 | "deff712f05a90d96edbd70facc47d944be5897e3", | |
100 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", |
|
100 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |
101 | "7e61ac704deecde634b51e59daa8110435dcb3da", |
|
101 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |
102 | ] |
|
102 | ] | |
103 | @repository.changesets.each do |rev| |
|
103 | @repository.changesets.each do |rev| | |
104 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } |
|
104 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |
105 | end |
|
105 | end | |
106 | @repository.reload |
|
106 | @repository.reload | |
107 | cs1 = @repository.changesets |
|
107 | cs1 = @repository.changesets | |
108 | assert_equal 15, cs1.count |
|
108 | assert_equal 15, cs1.count | |
109 | h = @repository.extra_info.dup |
|
109 | h = @repository.extra_info.dup | |
110 | h["branches"]["master"]["last_scmid"] = |
|
110 | h["branches"]["master"]["last_scmid"] = | |
111 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" |
|
111 | "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8" | |
112 | @repository.merge_extra_info(h) |
|
112 | @repository.merge_extra_info(h) | |
113 | @repository.save |
|
113 | @repository.save | |
114 | @repository.reload |
|
114 | @repository.reload | |
115 | extra_info_db_1 = @repository.extra_info["branches"] |
|
115 | extra_info_db_1 = @repository.extra_info["branches"] | |
116 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", |
|
116 | assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", | |
117 | extra_info_db_1["master"]["last_scmid"] |
|
117 | extra_info_db_1["master"]["last_scmid"] | |
118 |
|
118 | |||
119 | @repository.fetch_changesets |
|
119 | @repository.fetch_changesets | |
120 | assert_equal 21, @repository.changesets.count |
|
120 | assert_equal 21, @repository.changesets.count | |
121 | end |
|
121 | end | |
122 |
|
122 | |||
|
123 | def test_fetch_changesets_invalid_rev | |||
|
124 | @repository.fetch_changesets | |||
|
125 | @repository.reload | |||
|
126 | assert_equal 21, @repository.changesets.count | |||
|
127 | assert_equal 33, @repository.changes.count | |||
|
128 | extra_info_db = @repository.extra_info["branches"] | |||
|
129 | assert_equal 4, extra_info_db.size | |||
|
130 | assert_equal "1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127", | |||
|
131 | extra_info_db["latin-1-path-encoding"]["last_scmid"] | |||
|
132 | assert_equal "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |||
|
133 | extra_info_db["master"]["last_scmid"] | |||
|
134 | ||||
|
135 | del_revs = [ | |||
|
136 | "83ca5fd546063a3c7dc2e568ba3355661a9e2b2c", | |||
|
137 | "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", | |||
|
138 | "4f26664364207fa8b1af9f8722647ab2d4ac5d43", | |||
|
139 | "deff712f05a90d96edbd70facc47d944be5897e3", | |||
|
140 | "32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf", | |||
|
141 | "7e61ac704deecde634b51e59daa8110435dcb3da", | |||
|
142 | ] | |||
|
143 | @repository.changesets.each do |rev| | |||
|
144 | rev.destroy if del_revs.detect {|r| r == rev.scmid.to_s } | |||
|
145 | end | |||
|
146 | @repository.reload | |||
|
147 | cs1 = @repository.changesets | |||
|
148 | assert_equal 15, cs1.count | |||
|
149 | h = @repository.extra_info.dup | |||
|
150 | h["branches"]["master"]["last_scmid"] = | |||
|
151 | "abcd1234efgh" | |||
|
152 | @repository.merge_extra_info(h) | |||
|
153 | @repository.save | |||
|
154 | @repository.reload | |||
|
155 | extra_info_db_1 = @repository.extra_info["branches"] | |||
|
156 | assert_equal "abcd1234efgh", | |||
|
157 | extra_info_db_1["master"]["last_scmid"] | |||
|
158 | ||||
|
159 | @repository.fetch_changesets | |||
|
160 | assert_equal 15, @repository.changesets.count | |||
|
161 | end | |||
|
162 | ||||
123 | def test_latest_changesets |
|
163 | def test_latest_changesets | |
124 | @repository.fetch_changesets |
|
164 | @repository.fetch_changesets | |
125 | @repository.reload |
|
165 | @repository.reload | |
126 | # with limit |
|
166 | # with limit | |
127 | changesets = @repository.latest_changesets('', nil, 2) |
|
167 | changesets = @repository.latest_changesets('', nil, 2) | |
128 | assert_equal 2, changesets.size |
|
168 | assert_equal 2, changesets.size | |
129 |
|
169 | |||
130 | # with path |
|
170 | # with path | |
131 | changesets = @repository.latest_changesets('images', nil) |
|
171 | changesets = @repository.latest_changesets('images', nil) | |
132 | assert_equal [ |
|
172 | assert_equal [ | |
133 | 'deff712f05a90d96edbd70facc47d944be5897e3', |
|
173 | 'deff712f05a90d96edbd70facc47d944be5897e3', | |
134 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
174 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
135 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
175 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
136 | ], changesets.collect(&:revision) |
|
176 | ], changesets.collect(&:revision) | |
137 |
|
177 | |||
138 | changesets = @repository.latest_changesets('README', nil) |
|
178 | changesets = @repository.latest_changesets('README', nil) | |
139 | assert_equal [ |
|
179 | assert_equal [ | |
140 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', |
|
180 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', | |
141 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', |
|
181 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', | |
142 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
182 | '713f4944648826f558cf548222f813dabe7cbb04', | |
143 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
183 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
144 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
184 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
145 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
185 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
146 | ], changesets.collect(&:revision) |
|
186 | ], changesets.collect(&:revision) | |
147 |
|
187 | |||
148 | # with path, revision and limit |
|
188 | # with path, revision and limit | |
149 | changesets = @repository.latest_changesets('images', '899a15dba') |
|
189 | changesets = @repository.latest_changesets('images', '899a15dba') | |
150 | assert_equal [ |
|
190 | assert_equal [ | |
151 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
191 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
152 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
192 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
153 | ], changesets.collect(&:revision) |
|
193 | ], changesets.collect(&:revision) | |
154 |
|
194 | |||
155 | changesets = @repository.latest_changesets('images', '899a15dba', 1) |
|
195 | changesets = @repository.latest_changesets('images', '899a15dba', 1) | |
156 | assert_equal [ |
|
196 | assert_equal [ | |
157 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
197 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
158 | ], changesets.collect(&:revision) |
|
198 | ], changesets.collect(&:revision) | |
159 |
|
199 | |||
160 | changesets = @repository.latest_changesets('README', '899a15dba') |
|
200 | changesets = @repository.latest_changesets('README', '899a15dba') | |
161 | assert_equal [ |
|
201 | assert_equal [ | |
162 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
202 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
163 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
203 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
164 | ], changesets.collect(&:revision) |
|
204 | ], changesets.collect(&:revision) | |
165 |
|
205 | |||
166 | changesets = @repository.latest_changesets('README', '899a15dba', 1) |
|
206 | changesets = @repository.latest_changesets('README', '899a15dba', 1) | |
167 | assert_equal [ |
|
207 | assert_equal [ | |
168 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
208 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
169 | ], changesets.collect(&:revision) |
|
209 | ], changesets.collect(&:revision) | |
170 |
|
210 | |||
171 | # with path, tag and limit |
|
211 | # with path, tag and limit | |
172 | changesets = @repository.latest_changesets('images', 'tag01.annotated') |
|
212 | changesets = @repository.latest_changesets('images', 'tag01.annotated') | |
173 | assert_equal [ |
|
213 | assert_equal [ | |
174 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
214 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
175 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
215 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
176 | ], changesets.collect(&:revision) |
|
216 | ], changesets.collect(&:revision) | |
177 |
|
217 | |||
178 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) |
|
218 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) | |
179 | assert_equal [ |
|
219 | assert_equal [ | |
180 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
220 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
181 | ], changesets.collect(&:revision) |
|
221 | ], changesets.collect(&:revision) | |
182 |
|
222 | |||
183 | changesets = @repository.latest_changesets('README', 'tag01.annotated') |
|
223 | changesets = @repository.latest_changesets('README', 'tag01.annotated') | |
184 | assert_equal [ |
|
224 | assert_equal [ | |
185 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
225 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
186 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
226 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
187 | ], changesets.collect(&:revision) |
|
227 | ], changesets.collect(&:revision) | |
188 |
|
228 | |||
189 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) |
|
229 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) | |
190 | assert_equal [ |
|
230 | assert_equal [ | |
191 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
231 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
192 | ], changesets.collect(&:revision) |
|
232 | ], changesets.collect(&:revision) | |
193 |
|
233 | |||
194 | # with path, branch and limit |
|
234 | # with path, branch and limit | |
195 | changesets = @repository.latest_changesets('images', 'test_branch') |
|
235 | changesets = @repository.latest_changesets('images', 'test_branch') | |
196 | assert_equal [ |
|
236 | assert_equal [ | |
197 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
237 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
198 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
238 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
199 | ], changesets.collect(&:revision) |
|
239 | ], changesets.collect(&:revision) | |
200 |
|
240 | |||
201 | changesets = @repository.latest_changesets('images', 'test_branch', 1) |
|
241 | changesets = @repository.latest_changesets('images', 'test_branch', 1) | |
202 | assert_equal [ |
|
242 | assert_equal [ | |
203 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
243 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
204 | ], changesets.collect(&:revision) |
|
244 | ], changesets.collect(&:revision) | |
205 |
|
245 | |||
206 | changesets = @repository.latest_changesets('README', 'test_branch') |
|
246 | changesets = @repository.latest_changesets('README', 'test_branch') | |
207 | assert_equal [ |
|
247 | assert_equal [ | |
208 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
248 | '713f4944648826f558cf548222f813dabe7cbb04', | |
209 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
249 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
210 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
250 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
211 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
251 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
212 | ], changesets.collect(&:revision) |
|
252 | ], changesets.collect(&:revision) | |
213 |
|
253 | |||
214 | changesets = @repository.latest_changesets('README', 'test_branch', 2) |
|
254 | changesets = @repository.latest_changesets('README', 'test_branch', 2) | |
215 | assert_equal [ |
|
255 | assert_equal [ | |
216 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
256 | '713f4944648826f558cf548222f813dabe7cbb04', | |
217 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
257 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
218 | ], changesets.collect(&:revision) |
|
258 | ], changesets.collect(&:revision) | |
219 |
|
259 | |||
220 | # latin-1 encoding path |
|
260 | # latin-1 encoding path | |
221 | changesets = @repository.latest_changesets( |
|
261 | changesets = @repository.latest_changesets( | |
222 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') |
|
262 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') | |
223 | assert_equal [ |
|
263 | assert_equal [ | |
224 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
264 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
225 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', |
|
265 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', | |
226 | ], changesets.collect(&:revision) |
|
266 | ], changesets.collect(&:revision) | |
227 |
|
267 | |||
228 | changesets = @repository.latest_changesets( |
|
268 | changesets = @repository.latest_changesets( | |
229 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) |
|
269 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) | |
230 | assert_equal [ |
|
270 | assert_equal [ | |
231 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
271 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
232 | ], changesets.collect(&:revision) |
|
272 | ], changesets.collect(&:revision) | |
233 | end |
|
273 | end | |
234 |
|
274 | |||
235 | def test_latest_changesets_latin_1_dir |
|
275 | def test_latest_changesets_latin_1_dir | |
236 | if WINDOWS_PASS |
|
276 | if WINDOWS_PASS | |
237 | # |
|
277 | # | |
238 | else |
|
278 | else | |
239 | @repository.fetch_changesets |
|
279 | @repository.fetch_changesets | |
240 | @repository.reload |
|
280 | @repository.reload | |
241 | changesets = @repository.latest_changesets( |
|
281 | changesets = @repository.latest_changesets( | |
242 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') |
|
282 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') | |
243 | assert_equal [ |
|
283 | assert_equal [ | |
244 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', |
|
284 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', | |
245 | ], changesets.collect(&:revision) |
|
285 | ], changesets.collect(&:revision) | |
246 | end |
|
286 | end | |
247 | end |
|
287 | end | |
248 |
|
288 | |||
249 | def test_find_changeset_by_name |
|
289 | def test_find_changeset_by_name | |
250 | @repository.fetch_changesets |
|
290 | @repository.fetch_changesets | |
251 | @repository.reload |
|
291 | @repository.reload | |
252 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| |
|
292 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| | |
253 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
293 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
254 | @repository.find_changeset_by_name(r).revision |
|
294 | @repository.find_changeset_by_name(r).revision | |
255 | end |
|
295 | end | |
256 | end |
|
296 | end | |
257 |
|
297 | |||
258 | def test_find_changeset_by_empty_name |
|
298 | def test_find_changeset_by_empty_name | |
259 | @repository.fetch_changesets |
|
299 | @repository.fetch_changesets | |
260 | @repository.reload |
|
300 | @repository.reload | |
261 | ['', ' ', nil].each do |r| |
|
301 | ['', ' ', nil].each do |r| | |
262 | assert_nil @repository.find_changeset_by_name(r) |
|
302 | assert_nil @repository.find_changeset_by_name(r) | |
263 | end |
|
303 | end | |
264 | end |
|
304 | end | |
265 |
|
305 | |||
266 | def test_identifier |
|
306 | def test_identifier | |
267 | @repository.fetch_changesets |
|
307 | @repository.fetch_changesets | |
268 | @repository.reload |
|
308 | @repository.reload | |
269 | c = @repository.changesets.find_by_revision( |
|
309 | c = @repository.changesets.find_by_revision( | |
270 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
310 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
271 | assert_equal c.scmid, c.identifier |
|
311 | assert_equal c.scmid, c.identifier | |
272 | end |
|
312 | end | |
273 |
|
313 | |||
274 | def test_format_identifier |
|
314 | def test_format_identifier | |
275 | @repository.fetch_changesets |
|
315 | @repository.fetch_changesets | |
276 | @repository.reload |
|
316 | @repository.reload | |
277 | c = @repository.changesets.find_by_revision( |
|
317 | c = @repository.changesets.find_by_revision( | |
278 | '7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
318 | '7234cb2750b63f47bff735edc50a1c0a433c2518') | |
279 | assert_equal '7234cb27', c.format_identifier |
|
319 | assert_equal '7234cb27', c.format_identifier | |
280 | end |
|
320 | end | |
281 |
|
321 | |||
282 | def test_activities |
|
322 | def test_activities | |
283 | c = Changeset.new(:repository => @repository, |
|
323 | c = Changeset.new(:repository => @repository, | |
284 | :committed_on => Time.now, |
|
324 | :committed_on => Time.now, | |
285 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
325 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
286 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
326 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
287 | :comments => 'test') |
|
327 | :comments => 'test') | |
288 | assert c.event_title.include?('abc7234c:') |
|
328 | assert c.event_title.include?('abc7234c:') | |
289 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] |
|
329 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] | |
290 | end |
|
330 | end | |
291 |
|
331 | |||
292 | def test_log_utf8 |
|
332 | def test_log_utf8 | |
293 | @repository.fetch_changesets |
|
333 | @repository.fetch_changesets | |
294 | @repository.reload |
|
334 | @repository.reload | |
295 | str_felix_hex = FELIX_HEX.dup |
|
335 | str_felix_hex = FELIX_HEX.dup | |
296 | if str_felix_hex.respond_to?(:force_encoding) |
|
336 | if str_felix_hex.respond_to?(:force_encoding) | |
297 | str_felix_hex.force_encoding('UTF-8') |
|
337 | str_felix_hex.force_encoding('UTF-8') | |
298 | end |
|
338 | end | |
299 | c = @repository.changesets.find_by_revision( |
|
339 | c = @repository.changesets.find_by_revision( | |
300 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') |
|
340 | 'ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |
301 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer |
|
341 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer | |
302 | end |
|
342 | end | |
303 |
|
343 | |||
304 | def test_previous |
|
344 | def test_previous | |
305 | @repository.fetch_changesets |
|
345 | @repository.fetch_changesets | |
306 | @repository.reload |
|
346 | @repository.reload | |
307 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
347 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
308 | changeset = @repository.find_changeset_by_name(r1) |
|
348 | changeset = @repository.find_changeset_by_name(r1) | |
309 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
349 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
310 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
350 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous | |
311 | end |
|
351 | end | |
312 | end |
|
352 | end | |
313 | end |
|
353 | end | |
314 |
|
354 | |||
315 | def test_previous_nil |
|
355 | def test_previous_nil | |
316 | @repository.fetch_changesets |
|
356 | @repository.fetch_changesets | |
317 | @repository.reload |
|
357 | @repository.reload | |
318 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1| |
|
358 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1| | |
319 | changeset = @repository.find_changeset_by_name(r1) |
|
359 | changeset = @repository.find_changeset_by_name(r1) | |
320 | assert_nil changeset.previous |
|
360 | assert_nil changeset.previous | |
321 | end |
|
361 | end | |
322 | end |
|
362 | end | |
323 |
|
363 | |||
324 | def test_next |
|
364 | def test_next | |
325 | @repository.fetch_changesets |
|
365 | @repository.fetch_changesets | |
326 | @repository.reload |
|
366 | @repository.reload | |
327 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
367 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
328 | changeset = @repository.find_changeset_by_name(r2) |
|
368 | changeset = @repository.find_changeset_by_name(r2) | |
329 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
369 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
330 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
370 | assert_equal @repository.find_changeset_by_name(r1), changeset.next | |
331 | end |
|
371 | end | |
332 | end |
|
372 | end | |
333 | end |
|
373 | end | |
334 |
|
374 | |||
335 | def test_next_nil |
|
375 | def test_next_nil | |
336 | @repository.fetch_changesets |
|
376 | @repository.fetch_changesets | |
337 | @repository.reload |
|
377 | @repository.reload | |
338 | %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1| |
|
378 | %w|67e7792ce20ccae2e4bb73eed09bb397819c8834 67e7792ce20cca|.each do |r1| | |
339 | changeset = @repository.find_changeset_by_name(r1) |
|
379 | changeset = @repository.find_changeset_by_name(r1) | |
340 | assert_nil changeset.next |
|
380 | assert_nil changeset.next | |
341 | end |
|
381 | end | |
342 | end |
|
382 | end | |
343 | else |
|
383 | else | |
344 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
384 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" | |
345 | def test_fake; assert true end |
|
385 | def test_fake; assert true end | |
346 | end |
|
386 | end | |
347 | end |
|
387 | end |
General Comments 0
You need to be logged in to leave comments.
Login now