diff --git a/controller/repo.go b/controller/repo.go index d3f283722..3e9f86948 100644 --- a/controller/repo.go +++ b/controller/repo.go @@ -63,7 +63,7 @@ func PostRepo(c *gin.Context) { t := token.New(token.HookToken, r.FullName) sig, err := t.Sign(r.Hash) if err != nil { - c.AbortWithError(500, err) + c.String(500, err.Error()) return } @@ -76,7 +76,7 @@ func PostRepo(c *gin.Context) { // generate an RSA key and add to the repo key, err := crypto.GeneratePrivateKey() if err != nil { - c.AbortWithError(500, err) + c.String(500, err.Error()) return } keys := new(model.Key) @@ -87,20 +87,20 @@ func PostRepo(c *gin.Context) { // local changes to the database. err = remote.Activate(user, r, keys, link) if err != nil { - c.AbortWithError(500, err) + c.String(500, err.Error()) return } // persist the repository err = store.CreateRepo(c, r) if err != nil { - c.AbortWithError(500, err) + c.String(500, err.Error()) return } keys.RepoID = r.ID err = store.CreateKey(c, keys) if err != nil { - c.AbortWithError(500, err) + c.String(500, err.Error()) return } diff --git a/remote/bitbucket/bitbucket.go b/remote/bitbucket/bitbucket.go index 98d43df63..d1110c7b0 100644 --- a/remote/bitbucket/bitbucket.go +++ b/remote/bitbucket/bitbucket.go @@ -294,6 +294,7 @@ func (bb *Bitbucket) Activate(u *model.User, r *model.Repo, k *model.Key, link s linkurl, err := url.Parse(link) if err != nil { + log.Errorf("malformed hook url %s. %s", link, err) return err } @@ -303,7 +304,7 @@ func (bb *Bitbucket) Activate(u *model.User, r *model.Repo, k *model.Key, link s for _, hook := range hooks.Values { hookurl, err := url.Parse(hook.Url) if err != nil { - return err + continue } if hookurl.Host == linkurl.Host { err = client.DeleteHook(r.Owner, r.Name, hook.Uuid) @@ -314,12 +315,16 @@ func (bb *Bitbucket) Activate(u *model.User, r *model.Repo, k *model.Key, link s } } - return client.CreateHook(r.Owner, r.Name, &Hook{ + err = client.CreateHook(r.Owner, r.Name, &Hook{ Active: true, Desc: linkurl.Host, Events: []string{"repo:push"}, Url: link, }) + if err != nil { + log.Errorf("unable to create hook %s. %s", link, err) + } + return err } // Deactivate removes a repository by removing all the post-commit hooks