@@ -194,6 +194,13 class Repository::Git < Repository | |||
|
194 | 194 | end |
|
195 | 195 | private :save_revision |
|
196 | 196 | |
|
197 | def heads_from_branches_hash | |
|
198 | h1 = extra_info || {} | |
|
199 | h = h1.dup | |
|
200 | h["branches"] ||= {} | |
|
201 | h['branches'].map{|br, hs| hs['last_scmid']} | |
|
202 | end | |
|
203 | ||
|
197 | 204 | def latest_changesets(path,rev,limit=10) |
|
198 | 205 | revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false) |
|
199 | 206 | return [] if revisions.nil? || revisions.empty? |
@@ -244,6 +244,22 class RepositoryGitTest < ActiveSupport::TestCase | |||
|
244 | 244 | assert_equal 0, @repository.extra_info["db_consistent"]["ordering"] |
|
245 | 245 | end |
|
246 | 246 | |
|
247 | def test_heads_from_branches_hash | |
|
248 | assert_nil @repository.extra_info | |
|
249 | assert_equal 0, @repository.changesets.count | |
|
250 | assert_equal [], @repository.heads_from_branches_hash | |
|
251 | h = {} | |
|
252 | h["branches"] = {} | |
|
253 | h["branches"]["test1"] = {} | |
|
254 | h["branches"]["test1"]["last_scmid"] = "1234abcd" | |
|
255 | h["branches"]["test2"] = {} | |
|
256 | h["branches"]["test2"]["last_scmid"] = "abcd1234" | |
|
257 | @repository.merge_extra_info(h) | |
|
258 | @repository.save | |
|
259 | @project.reload | |
|
260 | assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort | |
|
261 | end | |
|
262 | ||
|
247 | 263 | def test_latest_changesets |
|
248 | 264 | assert_equal 0, @repository.changesets.count |
|
249 | 265 | @repository.fetch_changesets |
General Comments 0
You need to be logged in to leave comments.
Login now