httpapi: Use repo.Name instead of URI for URL construction#51525
Conversation
Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
6a896c3 to
31702ea
Compare
|
@indradhanush you have a typo in the PR title and the commit :) |
|
Good catch! Fixed. |
keegancsmith
left a comment
There was a problem hiding this comment.
Nice. I just audited all call sites to URI and this was the only misuse. We should consider removing this from the exported type to be honest.
In fact there was only one call site which read the value and luckily it did it correctly. Otherwise it was only used by code host syncers to write the value. Context: the only reason we store this value is we transparently look up by URI if looking up by Name fails to support the code host extensions correctly finding repos if sourcegraph is configured with a non-default repo name pattern.
Someone wanna send a PR which renames the field to URIDoNotUse or something? :D
|
@keegancsmith Thanks for the context. This looks like a nice good-first-issue. I'm pairing with @Rhia2 early next week and was in the hunt for something small and well scoped. @Rhia2 Maybe we can take a look at this in that case if you're interested. |
|
@indradhanush could we get this one backported so it lands in |
Fixes sourcegraph/customer#2113. For repos synced with `src server-git` the URI is set to `repos/<repo-name>` in the database. This leads to an incorrect URL in the git-blames when the feature flag `enable-streaming-git-blame` is enabled. Instead we should use the `repo.Name` because: 1. For regular code hosts like GitHub.com, it is set to: `github.com/sourcegraph/sourcegraph` 2. For `src serve-git`, it is set to `sourcegraph` (provided that's the repo being served) Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr> (cherry picked from commit f8128ce)
|
@DaedalusG Yes, good point. Backporting now. |
Fixes https://github.com/sourcegraph/customer/issues/2113.
For repos synced with
src server-gitthe URI is set torepos/<repo-name>in the database. This leads to an incorrect URL in the git-blames when the feature flagenable-streaming-git-blameis enabled.Instead we should use the
repo.Namebecause:github.com/sourcegraph/sourcegraphsrc serve-git, it is set tosourcegraph(provided that's the repo being served)Using the
repo.Namein the URL construction fixes the issue.Test plan