提交 6a1b17c4 编写于 作者: D Douwe Maan

Merge branch 'fix/gb/make-root-ref-default-instead-of-head' into 'master'

Use root ref instead of HEAD to find latest repository commit

Closes gitlab-ee#5864

See merge request gitlab-org/gitlab-ce!20258
......@@ -99,11 +99,11 @@ class Repository
"#<#{self.class.name}:#{@disk_path}>"
end
def commit(ref = 'HEAD')
def commit(ref = nil)
return nil unless exists?
return ref if ref.is_a?(::Commit)
find_commit(ref)
find_commit(ref || root_ref)
end
# Finding a commit by the passed SHA
......
......@@ -479,6 +479,14 @@ describe Repository do
end
end
context 'when ref is not specified' do
it 'is using a root ref' do
expect(repository).to receive(:find_commit).with('master')
repository.commit
end
end
context 'when ref is not valid' do
context 'when preceding tree element exists' do
it 'returns nil' do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册