Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Friendlier error message on update repo #903

Merged
merged 7 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @kaduartur @victor-schumacher @victorschumacherzup @brunasilvazup @lucasdittrichzup @henriquemoraeszup @rodrigomedeirosf @ernelio
* @kaduartur @victor-schumacher @victorschumacherzup @brunasilvazup @lucasdittrichzup @henriquemoraeszup @rodrigomedeirosf @ernelio @fernandobelettizup
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Bruna Tavares <silvatavares.bruna@gmail.com>
Ernélio Júnior <erneliojunior@gmail.com>
Fernando Beletti <fernando.beletti@zup.com.br>
Gabriel Pinheiro <gabrielctpinheiro@gmail.com>
Guillaume Falourd <guillaume.falourd@zup.com.br>
Harirai Mahajan <harim1709@gmail.com>
Expand Down
10 changes: 9 additions & 1 deletion pkg/git/bitbucket/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import (
"github.com/ZupIT/ritchie-cli/pkg/http/headers"
)

var ErrRepoNotFound = errors.New(
`could not retrieve new versions for selected repository
fernandobelettizup marked this conversation as resolved.
Show resolved Hide resolved
Please check if it still exists or changed visiblity
Try adding it again using:
rit add repo`)

type RepoManager struct {
client *http.Client
}
Expand Down Expand Up @@ -69,7 +75,9 @@ func (re RepoManager) Tags(info git.RepoInfo) (git.Tags, error) {

defer res.Body.Close()

if res.StatusCode != http.StatusOK {
if res.StatusCode == http.StatusForbidden || res.StatusCode == http.StatusNotFound {
return git.Tags{}, ErrRepoNotFound
} else if res.StatusCode != http.StatusOK {
all, _ := ioutil.ReadAll(res.Body)
return git.Tags{}, errors.New(res.Status + "-" + string(all))
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/git/github/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import (
"github.com/ZupIT/ritchie-cli/pkg/http/headers"
)

var ErrRepoNotFound = errors.New(
`could not retrieve new versions for selected repository
Please check if it still exists or changed visiblity
Try adding it again using:
rit add repo`)

type RepoManager struct {
client *http.Client
}
Expand Down Expand Up @@ -60,7 +66,9 @@ func (re RepoManager) Tags(info git.RepoInfo) (git.Tags, error) {
}

defer res.Body.Close()
if res.StatusCode != http.StatusOK {
if res.StatusCode == http.StatusNotFound {
return git.Tags{}, ErrRepoNotFound
} else if res.StatusCode != http.StatusOK {
all, _ := ioutil.ReadAll(res.Body)
return git.Tags{}, errors.New(res.Status + "-" + string(all))
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/git/gitlab/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import (
"github.com/ZupIT/ritchie-cli/pkg/http/headers"
)

var ErrRepoNotFound = errors.New(
`could not retrieve new versions for selected repository
Please check if it still exists or changed visiblity
Try adding it again using:
rit add repo`)

type RepoManager struct {
client *http.Client
}
Expand Down Expand Up @@ -60,7 +66,9 @@ func (re RepoManager) Tags(info git.RepoInfo) (git.Tags, error) {

defer res.Body.Close()

if res.StatusCode != http.StatusOK {
if res.StatusCode == http.StatusNotFound {
return git.Tags{}, ErrRepoNotFound
} else if res.StatusCode != http.StatusOK {
all, _ := ioutil.ReadAll(res.Body)
return git.Tags{}, errors.New(res.Status + "-" + string(all))
}
Expand Down