Conversation
| if len(repos) <= 1 && len(r.remotes) > 0 { | ||
| return r.remotes[0], nil | ||
| } |
There was a problem hiding this comment.
Maybe this is an obscure edge case but what about a case where there are multiple remotes and they only resolve to a single repo? Returning r.remotes[0] seems like it could result in the wrong remote getting selected. What about:
// Maintain current behavior in this case.
if len(repos) == 0 {
return r.remotes[0], nil
}
if len(repos) == 1 {
return repos[0], nil
}There was a problem hiding this comment.
I'm not worried about it. The shape of the RepoNetwork is directly related to the list of remotes locally. Multiple remotes all resolving to a single repo is a strange enough edge-case that I don't think we have to handle it.
There was a problem hiding this comment.
That one does seem unlikely. What about:
Remote 0 -> does not resolve to any GitHub repos because of auth issue or it is malformed remote or the repo was archived/deleted/renamed/etc
Remote 1 -> resolves to one GitHub repo
This is the one I was more concerned about. Normally you would think that an error would pop up and we wouldn't reach this point but the RepoNetwork query tolerates repo not found errors and so a remote can result in not resolving to any repo at all.
Going to approve the PR as the code looks good. Feel free to address this edge case if you feel it is relevant.
There was a problem hiding this comment.
ah, I see, thanks for elaborating; I wasn't interpreting your edge case correctly.
I do think there is merit in handling this after all so I'll push a commit for that.
After a clone,
ghwould fail to set a base repo even if there was only one remote. this only happened if the repository cloned was not owned by the cloner.Fixes #6792