Commit 4987f9e4 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-elasticsearch-blob-link' into 'master'

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.

See merge request !181
parents 4fb44484 60dc8261
Please view this file on the master branch, on stable branches it's out of date.
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)
- 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)
......
......@@ -710,7 +710,7 @@ class Repository
end
def parse_search_result_from_elastic(result)
ref = result["_source"]["blob"]["oid"]
ref = result["_source"]["blob"]["commit_sha"]
filename = result["_source"]["blob"]["path"]
content = result["_source"]["blob"]["content"]
total_lines = content.lines.size
......
......@@ -369,7 +369,7 @@ describe Repository, models: true do
project = create :project
project.repository.index_commits
Repository.__elasticsearch__.refresh_index!
expect(project.repository.find_commits_by_message_with_elastic('initial').first).to be_a(Commit)
......@@ -393,6 +393,7 @@ describe Repository, models: true do
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.startline).to eq(2)
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