mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
adding some debugging code for #1280
This commit is contained in:
parent
49c387ba2a
commit
970cf0ecae
2 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue