Page MenuHomePhabricator

Codesearch: Fix ShoutHow repository viewer links to link to a viewable version of the matching file instead of prompting the user to download the file
Closed, ResolvedPublicBUG REPORT

Description

If you go to https://codesearch.wmcloud.org/shouthow/ and search for something that you know exists, say, curl_init for example (https://codesearch.wmcloud.org/shouthow/?q=curl_init&i=nope&files=&excludeFiles=&repos=), you get a bunch of results.

Currently the first match is extensions/API/ApiApp.body.php. Let's say you're curious about the context (as codesearch only shows five relevant lines of code) and you click on either the file name or the numbered lines. The URL points to https://git.legoktm.com/ashley/ShoutHow/blob/391c26018d1c08d7c64193d175738bd1cf057275/extensions/API/ApiApp.body.php which thus prompts you to download the file (because of /blob/ in the URL) instead of letting you simply view the file in your browser as you probably wanted to do in the first place.

For viewing the file, one has to use /src/ in the URL instead of /blob/.

(I believe we discussed the matter in the past and it was so that simply linking to the master branch instead of a certain hash like 391c26018d1c08d7c64193d175738bd1cf057275 in the aforementioned URL was not possible, at least definitely not easily. If it were, though, ideally we'd change the aforementioned URL to https://git.legoktm.com/ashley/ShoutHow/src/master/extensions/API/ApiApp.body.php but that's literally a "in a perfect world" scenario. I assume codesearch is updated sufficiently frequently that its data is never too many minutes/hours out of date, whereas the ShoutHow project is not even guaranteed to receive commits every week. :)

Event Timeline

Change #1015424 had a related patch set uploaded (by Krinkle; author: Krinkle):

[labs/codesearch@master] write_config: Change git.legoktm.com url-pattern to `/src/`

https://gerrit.wikimedia.org/r/1015424

Krinkle subscribed.

File browser URLs work in Gogs over /src/ the same way that /blob/ does in GitLab/GitHub, including support for SHA1 references the same way:

https://git.legoktm.com/ashley/ShoutHow/src/391c26018d1c08d7c64193d175738bd1cf057275/extensions/API/ApiApp.body.php#L8

Change #1015424 merged by jenkins-bot:

[labs/codesearch@master] write_config: Change git.legoktm.com url-pattern to `/src/`

https://gerrit.wikimedia.org/r/1015424

Krinkle triaged this task as Medium priority.

Deployed!