Commit 5a565a8c authored by tmaruyama's avatar tmaruyama

scm: git: add model method to get heads from extra_info branches hash (#8857)

git-svn-id: https://svn.redmine.org/redmine/trunk@8816 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent b4288e49
......@@ -194,6 +194,13 @@ class Repository::Git < Repository
end
private :save_revision
def heads_from_branches_hash
h1 = extra_info || {}
h = h1.dup
h["branches"] ||= {}
h['branches'].map{|br, hs| hs['last_scmid']}
end
def latest_changesets(path,rev,limit=10)
revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false)
return [] if revisions.nil? || revisions.empty?
......
......@@ -244,6 +244,22 @@ class RepositoryGitTest < ActiveSupport::TestCase
assert_equal 0, @repository.extra_info["db_consistent"]["ordering"]
end
def test_heads_from_branches_hash
assert_nil @repository.extra_info
assert_equal 0, @repository.changesets.count
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"
@repository.merge_extra_info(h)
@repository.save
@project.reload
assert_equal ["1234abcd", "abcd1234"], @repository.heads_from_branches_hash.sort
end
def test_latest_changesets
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment