Commit 05c2c15c authored by Sato Hiroyuki's avatar Sato Hiroyuki

Fix Gitlab::Git::Repository#commit returns wrong commit, if commit_id is "tag name".

parent 963ec234
...@@ -98,9 +98,7 @@ module ExtractsPath ...@@ -98,9 +98,7 @@ module ExtractsPath
@ref, @path = extract_ref(@id) @ref, @path = extract_ref(@id)
# It is used "@project.repository.commits(@ref, @path, 1, 0)", @commit = @project.repository.commit(@ref)
# because "@project.repository.commit(@ref)" returns wrong commit when @ref is tag name.
@commit = @project.repository.commits(@ref, @path, 1, 0).first
@tree = Tree.new(@project.repository, @commit.id, @ref, @path) @tree = Tree.new(@project.repository, @commit.id, @ref, @path)
......
...@@ -49,7 +49,16 @@ module Gitlab ...@@ -49,7 +49,16 @@ module Gitlab
def commit(commit_id = nil) def commit(commit_id = nil)
commit = if commit_id commit = if commit_id
repo.commit(commit_id) # Find repo.refs first,
# because if commit_id is "tag name",
# repo.commit(commit_id) returns wrong commit sha
# that is git tag object sha.
ref = repo.refs.find {|r| r.name == commit_id}
if ref
ref.commit
else
repo.commit(commit_id)
end
else else
repo.commits(root_ref).first repo.commits(root_ref).first
end end
......
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