From 9e75997f2f7f19f8c8724639e113b1ec3df7f2cc Mon Sep 17 00:00:00 2001 From: Piotr Icikowski Date: Thu, 28 Apr 2022 20:00:49 +0200 Subject: [PATCH] Another bugfix for application repository loaders processor --- application/repos/github.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application/repos/github.go b/application/repos/github.go index fa797df..643a0e0 100644 --- a/application/repos/github.go +++ b/application/repos/github.go @@ -47,7 +47,10 @@ func (l *GitHubRepositoryLoader) LoadRepository(source string) (types.Repository req.Header.Set("Accept", "application/vnd.github.v3+json") resp, err := http.DefaultClient.Do(req) - if err != nil { + if err != nil || resp.StatusCode != http.StatusOK { + if err == nil { + err = fmt.Errorf("got status code %d", resp.StatusCode) + } common.PrintErrorWhileMsg("detecting default branch of", fmt.Sprintf("%s/%s", user, repo), err) return repository, false } @@ -73,7 +76,10 @@ func (l *GitHubRepositoryLoader) LoadRepository(source string) (types.Repository req, _ := http.NewRequest(http.MethodGet, url, nil) resp, err := http.DefaultClient.Do(req) - if err != nil { + if err != nil || resp.StatusCode != http.StatusOK { + if err == nil { + err = fmt.Errorf("got status code %d", resp.StatusCode) + } common.PrintErrorWhileMsg("loading source", source, err) return repository, false }