search: restore clear error for empty remote URL · Entire
search: restore clear error for empty remote URL
42175e9→main·
pfleidi·1mo ago·2 files·+8 added/-3 removed
Trim the remote URL once up front and reject an empty value explicitly, restoring the "empty remote URL" message that delegating to gitremote.ParseURL had replaced with "no protocol in URL: ://". Using the trimmed value also keeps the redacted URL in the extra-segments error consistent with what was parsed.
Sessions
2e5d8b2d92fbView transcript
Fix Search to Accept Entire Mirror RemotesClaude Code·Opus 4.8[1m]·2 steps
Changes
2
cmd/entire/cli/search
Mgithub.go+5
- Msearch_test.go+3/-3
1 unmodified line
2
3
4
5
6
7
8
6 unmodified lines
15
16
17
18
19
20
21
22
23
24
1 unmodified line
package search
import (
"errors"
"fmt"
"strings"
6 unmodified lines
// whose forge prefix maps back to github.com. Remotes resolving to any other
// host, or whose path holds extra segments beyond owner/repo, are rejected.
func ParseGitHubRemote(remoteURL string) (owner, repo string, err error) {
remoteURL = strings.TrimSpace(remoteURL)
if remoteURL == "" {
return "", "", errors.New("empty remote URL")
}
info, err := gitremote.ParseURL(remoteURL)
if err != nil {
return "", "", fmt.Errorf("parsing remote URL: %w", err)
Mcmd/entire/cli/search/github.go+5
55 unmodified lines
56
57
58
59
60
61
59
60
61
62
63
64
55 unmodified lines
func TestParseGitHubRemote_Invalid(t *testing.T) {
t.Parallel()
_, _, err := ParseGitHubRemote("")
if err == nil {
t.Error("expected error for empty URL")
_, _, err := ParseGitHubRemote(" ")
if err == nil || err.Error() != "empty remote URL" {
t.Errorf("expected 'empty remote URL' for blank input, got %v", err)
}
_, _, err = ParseGitHubRemote("not-a-url")