Commit 60dc8261 authored by Stan Hu's avatar Stan Hu

Fix Elasticsearch blob results linking to the wrong reference ID

If Elasticsearch returned a hit for a blob, clicking on the link would
always return a 404 since the OID, not the commit SHA, was being used.
parent 4fb44484
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.5.0 (unreleased) v 8.5.0 (unreleased)
- Fix Elasticsearch blob results linking to the wrong reference ID (Stan Hu)
- Cache various Repository methods to improve performance (Yorick Peterse) - Cache various Repository methods to improve performance (Yorick Peterse)
- Ensure rake tasks that don't need a DB connection can be run without one - Ensure rake tasks that don't need a DB connection can be run without one
- Update New Relic gem to 3.14.1.311 (Stan Hu) - Update New Relic gem to 3.14.1.311 (Stan Hu)
......
...@@ -710,7 +710,7 @@ class Repository ...@@ -710,7 +710,7 @@ class Repository
end end
def parse_search_result_from_elastic(result) def parse_search_result_from_elastic(result)
ref = result["_source"]["blob"]["oid"] ref = result["_source"]["blob"]["commit_sha"]
filename = result["_source"]["blob"]["path"] filename = result["_source"]["blob"]["path"]
content = result["_source"]["blob"]["content"] content = result["_source"]["blob"]["content"]
total_lines = content.lines.size total_lines = content.lines.size
......
...@@ -369,7 +369,7 @@ describe Repository, models: true do ...@@ -369,7 +369,7 @@ describe Repository, models: true do
project = create :project project = create :project
project.repository.index_commits project.repository.index_commits
Repository.__elasticsearch__.refresh_index! Repository.__elasticsearch__.refresh_index!
expect(project.repository.find_commits_by_message_with_elastic('initial').first).to be_a(Commit) expect(project.repository.find_commits_by_message_with_elastic('initial').first).to be_a(Commit)
...@@ -393,6 +393,7 @@ describe Repository, models: true do ...@@ -393,6 +393,7 @@ describe Repository, models: true do
parsed_result = project.repository.parse_search_result_from_elastic(result) parsed_result = project.repository.parse_search_result_from_elastic(result)
expect(parsed_result.ref). to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
expect(parsed_result.filename).to eq('files/ruby/popen.rb') expect(parsed_result.filename).to eq('files/ruby/popen.rb')
expect(parsed_result.startline).to eq(2) expect(parsed_result.startline).to eq(2)
expect(parsed_result.data).to include("Popen") expect(parsed_result.data).to include("Popen")
......
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