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
This commit is contained in:
commit
6a1b17c4d5
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue