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)
|
t := token.New(token.HookToken, r.FullName)
|
||||||
sig, err := t.Sign(r.Hash)
|
sig, err := t.Sign(r.Hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(500, err)
|
c.String(500, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func PostRepo(c *gin.Context) {
|
||||||
// generate an RSA key and add to the repo
|
// generate an RSA key and add to the repo
|
||||||
key, err := crypto.GeneratePrivateKey()
|
key, err := crypto.GeneratePrivateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(500, err)
|
c.String(500, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
keys := new(model.Key)
|
keys := new(model.Key)
|
||||||
|
@ -87,20 +87,20 @@ func PostRepo(c *gin.Context) {
|
||||||
// local changes to the database.
|
// local changes to the database.
|
||||||
err = remote.Activate(user, r, keys, link)
|
err = remote.Activate(user, r, keys, link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(500, err)
|
c.String(500, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// persist the repository
|
// persist the repository
|
||||||
err = store.CreateRepo(c, r)
|
err = store.CreateRepo(c, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(500, err)
|
c.String(500, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
keys.RepoID = r.ID
|
keys.RepoID = r.ID
|
||||||
err = store.CreateKey(c, keys)
|
err = store.CreateKey(c, keys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(500, err)
|
c.String(500, err.Error())
|
||||||
return
|
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)
|
linkurl, err := url.Parse(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("malformed hook url %s. %s", link, err)
|
||||||
return 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 {
|
for _, hook := range hooks.Values {
|
||||||
hookurl, err := url.Parse(hook.Url)
|
hookurl, err := url.Parse(hook.Url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
continue
|
||||||
}
|
}
|
||||||
if hookurl.Host == linkurl.Host {
|
if hookurl.Host == linkurl.Host {
|
||||||
err = client.DeleteHook(r.Owner, r.Name, hook.Uuid)
|
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,
|
Active: true,
|
||||||
Desc: linkurl.Host,
|
Desc: linkurl.Host,
|
||||||
Events: []string{"repo:push"},
|
Events: []string{"repo:push"},
|
||||||
Url: link,
|
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
|
// Deactivate removes a repository by removing all the post-commit hooks
|
||||||
|
|
Loading…
Reference in a new issue