Defect #12505 » git.diff
| test/unit/repository_git_test.rb | ||
|---|---|---|
|
assert_equal [], @repository.heads_from_branches_hash
|
||
|
h = {}
|
||
|
h["branches"] = {}
|
||
|
h["branches"]["test1"] = {}
|
||
|
h["branches"]["test1"]["last_scmid"] = "1234abcd"
|
||
|
h["branches"]["test2"] = {}
|
||
|
h["branches"]["test2"]["last_scmid"] = "abcd1234"
|
||
|
h["branches"]["master"] = {}
|
||
|
h["branches"]["master"]["last_scmid"] = "7234cb2750b63f47bff735edc50a1c0a433c2518"
|
||
|
h["branches"]["master-20120212"] = {}
|
||
|
h["branches"]["master-20120212"]["last_scmid"] = "899a15dba03a3b350b89c3f537e4bbe02a03cdc9"
|
||
|
h["branches"]["test_branch"] = {}
|
||
|
h["branches"]["test_branch"]["last_scmid"] = "899a15dba03a3b350b89c3f537e4bbe02a03cdc9"
|
||
|
h["branches"]["deleted_branch"] = {}
|
||
|
h["branches"]["deleted_branch"]["last_scmid"] = "0123abcd"
|
||
|
@repository.merge_extra_info(h)
|
||
|
@repository.save
|
||
|
@project.reload
|
||
|
assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort
|
||
|
assert_equal ["0123abcd",
|
||
|
"7234cb2750b63f47bff735edc50a1c0a433c2518",
|
||
|
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9",
|
||
|
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9"],
|
||
|
@repository.heads_from_branches_hash.sort
|
||
|
end
|
||
|
def test_latest_changesets
|
||
| app/models/repository/git.rb | ||
|---|---|---|
|
h["heads"] ||= []
|
||
|
prev_db_heads = h["heads"].dup
|
||
|
if prev_db_heads.empty?
|
||
|
prev_db_heads += heads_from_branches_hash
|
||
|
prev_db_heads += heads_from_branches_hash(scm_brs)
|
||
|
end
|
||
|
return if prev_db_heads.sort == repo_heads.sort
|
||
| ... | ... | |
|
end
|
||
|
private :save_revision
|
||
|
def heads_from_branches_hash
|
||
|
def heads_from_branches_hash(git_branches)
|
||
|
br_names = git_branches.map{|br| br.to_s}
|
||
|
h1 = extra_info || {}
|
||
|
h = h1.dup
|
||
|
heads = []
|
||
|
h["branches"] ||= {}
|
||
|
h['branches'].map{|br, hs| hs['last_scmid']}
|
||
|
h['branches'].each do |br, hs|
|
||
|
heads << hs['last_scmid'] if br_names.include?(br)
|
||
|
end
|
||
|
heads
|
||
|
end
|
||
|
def latest_changesets(path,rev,limit=10)
|
||
| test/unit/repository_git_test.rb | ||
|---|---|---|
|
end
|
||
|
def test_heads_from_branches_hash
|
||
|
brs = @repository.branches
|
||
|
assert_nil @repository.extra_info
|
||
|
assert_equal 0, @repository.changesets.count
|
||
|
assert_equal [], @repository.heads_from_branches_hash
|
||
|
assert_equal [], @repository.heads_from_branches_hash(brs)
|
||
|
h = {}
|
||
|
h["branches"] = {}
|
||
|
h["branches"]["master"] = {}
|
||
| ... | ... | |
|
@repository.merge_extra_info(h)
|
||
|
@repository.save
|
||
|
@project.reload
|
||
|
assert_equal ["0123abcd",
|
||
|
"7234cb2750b63f47bff735edc50a1c0a433c2518",
|
||
|
assert_equal ["7234cb2750b63f47bff735edc50a1c0a433c2518",
|
||
|
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9",
|
||
|
"899a15dba03a3b350b89c3f537e4bbe02a03cdc9"],
|
||
|
@repository.heads_from_branches_hash.sort
|
||
|
@repository.heads_from_branches_hash(brs).sort
|
||
|
end
|
||
|
def test_latest_changesets
|
||
- « Previous
- 1
- 2
- Next »