Defect #12505 » git.diff
| test/unit/repository_git_test.rb | ||
|---|---|---|
| 334 | 334 |
assert_equal [], @repository.heads_from_branches_hash |
| 335 | 335 |
h = {}
|
| 336 | 336 |
h["branches"] = {}
|
| 337 |
h["branches"]["test1"] = {}
|
|
| 338 |
h["branches"]["test1"]["last_scmid"] = "1234abcd" |
|
| 339 |
h["branches"]["test2"] = {}
|
|
| 340 |
h["branches"]["test2"]["last_scmid"] = "abcd1234" |
|
| 337 |
h["branches"]["master"] = {}
|
|
| 338 |
h["branches"]["master"]["last_scmid"] = "7234cb2750b63f47bff735edc50a1c0a433c2518" |
|
| 339 |
h["branches"]["master-20120212"] = {}
|
|
| 340 |
h["branches"]["master-20120212"]["last_scmid"] = "899a15dba03a3b350b89c3f537e4bbe02a03cdc9" |
|
| 341 |
h["branches"]["test_branch"] = {}
|
|
| 342 |
h["branches"]["test_branch"]["last_scmid"] = "899a15dba03a3b350b89c3f537e4bbe02a03cdc9" |
|
| 343 |
h["branches"]["deleted_branch"] = {}
|
|
| 344 |
h["branches"]["deleted_branch"]["last_scmid"] = "0123abcd" |
|
| 341 | 345 |
@repository.merge_extra_info(h) |
| 342 | 346 |
@repository.save |
| 343 | 347 |
@project.reload |
| 344 |
assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort |
|
| 348 |
assert_equal ["0123abcd", |
|
| 349 |
"7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
| 350 |
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9", |
|
| 351 |
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9"], |
|
| 352 |
@repository.heads_from_branches_hash.sort |
|
| 345 | 353 |
end |
| 346 | 354 | |
| 347 | 355 |
def test_latest_changesets |
| app/models/repository/git.rb | ||
|---|---|---|
| 137 | 137 |
h["heads"] ||= [] |
| 138 | 138 |
prev_db_heads = h["heads"].dup |
| 139 | 139 |
if prev_db_heads.empty? |
| 140 |
prev_db_heads += heads_from_branches_hash |
|
| 140 |
prev_db_heads += heads_from_branches_hash(scm_brs)
|
|
| 141 | 141 |
end |
| 142 | 142 |
return if prev_db_heads.sort == repo_heads.sort |
| 143 | 143 | |
| ... | ... | |
| 235 | 235 |
end |
| 236 | 236 |
private :save_revision |
| 237 | 237 | |
| 238 |
def heads_from_branches_hash |
|
| 238 |
def heads_from_branches_hash(git_branches) |
|
| 239 |
br_names = git_branches.map{|br| br.to_s}
|
|
| 239 | 240 |
h1 = extra_info || {}
|
| 240 | 241 |
h = h1.dup |
| 242 |
heads = [] |
|
| 241 | 243 |
h["branches"] ||= {}
|
| 242 |
h['branches'].map{|br, hs| hs['last_scmid']}
|
|
| 244 |
h['branches'].each do |br, hs| |
|
| 245 |
heads << hs['last_scmid'] if br_names.include?(br) |
|
| 246 |
end |
|
| 247 |
heads |
|
| 243 | 248 |
end |
| 244 | 249 | |
| 245 | 250 |
def latest_changesets(path,rev,limit=10) |
| test/unit/repository_git_test.rb | ||
|---|---|---|
| 329 | 329 |
end |
| 330 | 330 | |
| 331 | 331 |
def test_heads_from_branches_hash |
| 332 |
brs = @repository.branches |
|
| 332 | 333 |
assert_nil @repository.extra_info |
| 333 | 334 |
assert_equal 0, @repository.changesets.count |
| 334 |
assert_equal [], @repository.heads_from_branches_hash |
|
| 335 |
assert_equal [], @repository.heads_from_branches_hash(brs)
|
|
| 335 | 336 |
h = {}
|
| 336 | 337 |
h["branches"] = {}
|
| 337 | 338 |
h["branches"]["master"] = {}
|
| ... | ... | |
| 345 | 346 |
@repository.merge_extra_info(h) |
| 346 | 347 |
@repository.save |
| 347 | 348 |
@project.reload |
| 348 |
assert_equal ["0123abcd", |
|
| 349 |
"7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
| 349 |
assert_equal ["7234cb2750b63f47bff735edc50a1c0a433c2518", |
|
| 350 | 350 |
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9", |
| 351 | 351 |
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9"], |
| 352 |
@repository.heads_from_branches_hash.sort |
|
| 352 |
@repository.heads_from_branches_hash(brs).sort
|
|
| 353 | 353 |
end |
| 354 | 354 | |
| 355 | 355 |
def test_latest_changesets |
- « Previous
- 1
- 2
- Next »