Remove GitHub mentions in error messages
This commit is contained in:
parent
595f6e6a43
commit
482a86ec75
30
main.go
30
main.go
@ -131,7 +131,7 @@ go get {{.GopkgPath}}
|
||||
</html>
|
||||
`))
|
||||
|
||||
// Repo represents a source code repository on GitHub.
|
||||
// Repo represents a source code repository on a repo host.
|
||||
type Repo struct {
|
||||
User string
|
||||
Name string
|
||||
@ -186,7 +186,7 @@ var redirect = map[repoBase]repoBase{
|
||||
{"", "fsnotify"}: {"fsnotify", "fsnotify"},
|
||||
}
|
||||
|
||||
// GitHubRoot returns the repository root at GitHub, without a schema.
|
||||
// GitHubRoot returns the repository root, without a schema.
|
||||
func (repo *Repo) GitHubRoot() string {
|
||||
if *userFlag != "" {
|
||||
return *srcDomainFlag + "/" + *userFlag + "/" + repo.Name
|
||||
@ -197,7 +197,7 @@ func (repo *Repo) GitHubRoot() string {
|
||||
return *srcDomainFlag + "/" + repo.User + "/" + repo.Name
|
||||
}
|
||||
|
||||
// GitHubTree returns the repository tree name at GitHub for the selected version.
|
||||
// GitHubTree returns the repository tree name for the selected version.
|
||||
func (repo *Repo) GitHubTree() string {
|
||||
if repo.FullVersion == InvalidVersion {
|
||||
return "master"
|
||||
@ -304,7 +304,7 @@ func handler(resp http.ResponseWriter, req *http.Request) {
|
||||
case nil:
|
||||
// all ok
|
||||
case ErrNoRepo:
|
||||
sendNotFound(resp, "GitHub repository not found at https://%s", repo.GitHubRoot())
|
||||
sendNotFound(resp, "Repository not found at https://%s", repo.GitHubRoot())
|
||||
return
|
||||
case ErrNoVersion:
|
||||
major := repo.MajorVersion
|
||||
@ -314,11 +314,11 @@ func handler(resp http.ResponseWriter, req *http.Request) {
|
||||
suffix = unstableSuffix
|
||||
}
|
||||
v := major.String()
|
||||
sendNotFound(resp, `GitHub repository at https://%s has no branch or tag "%s%s", "%s.N%s" or "%s.N.M%s"`, repo.GitHubRoot(), v, suffix, v, suffix, v, suffix)
|
||||
sendNotFound(resp, `Repository at https://%s has no branch or tag "%s%s", "%s.N%s" or "%s.N.M%s"`, repo.GitHubRoot(), v, suffix, v, suffix, v, suffix)
|
||||
return
|
||||
default:
|
||||
resp.WriteHeader(http.StatusBadGateway)
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot obtain refs from GitHub: %v", err)))
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot obtain refs from repo host: %v", err)))
|
||||
return
|
||||
}
|
||||
|
||||
@ -360,14 +360,14 @@ func proxyUploadPack(resp http.ResponseWriter, req *http.Request, repo *Repo) {
|
||||
preq, err := http.NewRequest(req.Method, "https://"+repo.GitHubRoot()+"/git-upload-pack", req.Body)
|
||||
if err != nil {
|
||||
resp.WriteHeader(http.StatusInternalServerError)
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot create GitHub request: %v", err)))
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot create request: %v", err)))
|
||||
return
|
||||
}
|
||||
preq.Header = req.Header
|
||||
presp, err := bulkClient.Do(preq)
|
||||
if err != nil {
|
||||
resp.WriteHeader(http.StatusBadGateway)
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot obtain data pack from GitHub: %v", err)))
|
||||
resp.Write([]byte(fmt.Sprintf("Cannot obtain data pack from repo host: %v", err)))
|
||||
return
|
||||
}
|
||||
defer presp.Body.Close()
|
||||
@ -381,17 +381,17 @@ func proxyUploadPack(resp http.ResponseWriter, req *http.Request, repo *Repo) {
|
||||
// Ignore errors. Dropped connections are usual and will make this fail.
|
||||
_, err = io.Copy(resp, presp.Body)
|
||||
if err != nil {
|
||||
log.Printf("Error copying data from GitHub: %v", err)
|
||||
log.Printf("Error copying data from repo host: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
var ErrNoRepo = errors.New("repository not found in GitHub")
|
||||
var ErrNoVersion = errors.New("version reference not found in GitHub")
|
||||
var ErrNoRepo = errors.New("repository not found on repo host")
|
||||
var ErrNoVersion = errors.New("version reference not found on repo host")
|
||||
|
||||
func fetchRefs(repo *Repo) (data []byte, err error) {
|
||||
resp, err := httpClient.Get("https://" + repo.GitHubRoot() + refsSuffix)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot talk to GitHub: %v", err)
|
||||
return nil, fmt.Errorf("cannot talk to repo host: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
@ -401,12 +401,12 @@ func fetchRefs(repo *Repo) (data []byte, err error) {
|
||||
case 401, 404:
|
||||
return nil, ErrNoRepo
|
||||
default:
|
||||
return nil, fmt.Errorf("error from GitHub: %v", resp.Status)
|
||||
return nil, fmt.Errorf("error from repo host: %v", resp.Status)
|
||||
}
|
||||
|
||||
data, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading from GitHub: %v", err)
|
||||
return nil, fmt.Errorf("error reading from repo host: %v", err)
|
||||
}
|
||||
return data, err
|
||||
}
|
||||
@ -432,7 +432,7 @@ func changeRefs(data []byte, major Version) (changed []byte, versions VersionLis
|
||||
}
|
||||
j = i + int(size)
|
||||
if j > len(sdata) {
|
||||
return nil, nil, fmt.Errorf("incomplete refs data received from GitHub")
|
||||
return nil, nil, fmt.Errorf("incomplete refs data received from repo host")
|
||||
}
|
||||
if sdata[0] == '#' {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user