mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
View better error if repo was deleted/renamed (#780)
If the repo was renamed, there's an issue with Gitea: it redirects the /api/v1/repos/<owner>/<repo>/hooks POST request to a GET request at the same URL. This URL returns the list of all hooks, thus the Gitea SDK can't parse the response into a single gitea.Hook type. A better error is also visisble if the repo was deleted.
This commit is contained in:
parent
c4960cdd2c
commit
28e96a3851
1 changed files with 13 additions and 2 deletions
|
@ -381,8 +381,19 @@ func (c *Gitea) Activate(ctx context.Context, u *model.User, r *model.Repo, link
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, _, err = client.CreateRepoHook(r.Owner, r.Name, hook)
|
||||
_, response, err := client.CreateRepoHook(r.Owner, r.Name, hook)
|
||||
if err != nil {
|
||||
if response != nil {
|
||||
if response.StatusCode == 404 {
|
||||
return fmt.Errorf("Could not find repository")
|
||||
}
|
||||
if response.StatusCode == 200 {
|
||||
return fmt.Errorf("Could not find repository, repository was probably renamed")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deactivate deactives the repository be removing repository push hooks from
|
||||
|
|
Loading…
Reference in a new issue