diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 976ac01820429b285a215200e42e7e7641bfeae7..fb595e18b2401123d9b47d4ff2a29c1c9136ca6d 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -117,7 +117,10 @@ module ExtractsPath
 
     @id = File.join(@ref, @path)
 
-    @commit = CommitDecorator.decorate(@project.repository.commit(@ref))
+    # It is used "@project.repository.commits(@ref, @path, 1, 0)",
+    # because "@project.repository.commit(@ref)" returns wrong commit when @ref is tag name.
+    commits = @project.repository.commits(@ref, @path, 1, 0)
+    @commit = CommitDecorator.decorate(commits.first)
 
     @tree = Tree.new(@commit.tree, @ref, @path)
     @tree = TreeDecorator.new(@tree)
diff --git a/lib/gitlab/graph/json_builder.rb b/lib/gitlab/graph/json_builder.rb
index 05e16f3d68378f2e2ac45caaec46e199276d070b..8f31c820be1c4bee3d99a818c3da904a6267b8b2 100644
--- a/lib/gitlab/graph/json_builder.rb
+++ b/lib/gitlab/graph/json_builder.rb
@@ -113,7 +113,7 @@ module Gitlab
 
       def include_ref?(commit)
         heads = commit.refs.select do |ref|
-          ref.is_a?(Grit::Head) or ref.is_a?(Grit::Remote)
+          ref.is_a?(Grit::Head) or ref.is_a?(Grit::Remote) or ref.is_a?(Grit::Tag)
         end
 
         heads.map! do |head|