Commit 1f192757 authored by Hiroyuki Sato's avatar Hiroyuki Sato

Rename sha to id

parent b1ca2c7d
...@@ -654,19 +654,19 @@ class Repository ...@@ -654,19 +654,19 @@ class Repository
end end
def last_commit_for_path(sha, path) def last_commit_for_path(sha, path)
sha = cache_last_commit_sha_for_path(sha, path) sha = cache_last_commit_id_for_path(sha, path)
commit(sha) commit(sha)
end end
def last_commit_sha_for_path(sha, path) def last_commit_id_for_path(sha, path)
args = %W(#{Gitlab.config.git.bin_path} rev-list --max-count=1 #{sha} -- #{path}) args = %W(#{Gitlab.config.git.bin_path} rev-list --max-count=1 #{sha} -- #{path})
Gitlab::Popen.popen(args, path_to_repo).first.strip Gitlab::Popen.popen(args, path_to_repo).first.strip
end end
def cache_last_commit_sha_for_path(sha, path) def cache_last_commit_id_for_path(sha, path)
key = path.blank? ? "last_commit_sha_for_path:#{sha}" : "last_commit_id_for_path:#{sha}:#{Digest::SHA1.hexdigest(path)}" key = path.blank? ? "last_commit_id_for_path:#{sha}" : "last_commit_id_for_path:#{sha}:#{Digest::SHA1.hexdigest(path)}"
cache.fetch(key) do cache.fetch(key) do
last_commit_sha_for_path(sha, path) last_commit_id_for_path(sha, path)
end end
end end
......
...@@ -70,7 +70,7 @@ module API ...@@ -70,7 +70,7 @@ module API
ref: params[:ref], ref: params[:ref],
blob_id: blob.id, blob_id: blob.id,
commit_id: commit.id, commit_id: commit.id,
last_commit_id: repo.cache_last_commit_sha_for_path(commit.sha, params[:file_path]) last_commit_id: repo.cache_last_commit_id_for_path(commit.sha, params[:file_path])
} }
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