#835: Realtime webhooks

This commit is contained in:
Unknwon committed 2015-07-25 21:32:04 +08:00
1 parent 2b1442f3df
commit fa298a2c30
13 files changed
+140 -69

No files matched your search

+7
View File
@@ -16,6 +16,7 @@ import (
"github.com/codegangsta/cli"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/httplib"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/uuid"
@@ -193,6 +194,12 @@ func runServ(c *cli.Context) {
}
}
// Send deliver hook request.
resp, err := httplib.Head(setting.AppUrl + setting.AppSubUrl + repoUserName + "/" + repoName + "/hooks/trigger").Response()
if err == nil {
resp.Body.Close()
}
// Update key activity.
key, err := models.GetPublicKeyById(keyId)
if err != nil {
+1
View File
@@ -451,6 +451,7 @@ func runWeb(ctx *cli.Context) {
m.Get("/archive/*", repo.Download)
m.Get("/pulls2/", repo.PullRequest2)
m.Get("/milestone2/", repo.Milestones2)
m.Head("/hooks/trigger", repo.TriggerHook)
m.Group("", func() {
m.Get("/src/*", repo.Home)
+2 -2
View File
@@ -91,8 +91,8 @@ ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = false
DISABLE_MINIMUM_KEY_SIZE_CHECK = false
[webhook]
; Cron task interval in minutes
TASK_INTERVAL = 1
; Hook task queue length
QUEUE_LENGTH = 1000
; Deliver timeout in seconds
DELIVER_TIMEOUT = 5
; Allow insecure certification
+1 -1
View File
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.6.2.0725 Beta"
const APP_VER = "0.6.3.0725 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
+2
View File
@@ -431,6 +431,8 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
}
if err = CreateHookTask(&HookTask{
RepoID: repo.Id,
HookID: w.Id,
Type: w.HookTaskType,
Url: w.Url,
BasePayload: payload,
+113 -59
View File
@@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"io/ioutil"
"sync"
"time"
"github.com/gogits/gogs/modules/httplib"
@@ -259,7 +260,9 @@ func (p Payload) GetJSONPayload() ([]byte, error) {
// HookTask represents a hook task.
type HookTask struct {
Id int64
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX"`
HookID int64
Uuid string
Type HookTaskType
Url string
@@ -269,6 +272,7 @@ type HookTask struct {
EventType HookEventType
IsSsl bool
IsDelivered bool
Delivered int64
IsSucceed bool
}
@@ -287,87 +291,137 @@ func CreateHookTask(t *HookTask) error {
// UpdateHookTask updates information of hook task.
func UpdateHookTask(t *HookTask) error {
_, err := x.Id(t.Id).AllCols().Update(t)
_, err := x.Id(t.ID).AllCols().Update(t)
return err
}
var (
// Prevent duplicate deliveries.
// This happens with massive hook tasks cannot finish delivering
// before next shooting starts.
isShooting = false
)
type hookQueue struct {
// Make sure one repository only occur once in the queue.
lock sync.Mutex
repoIDs map[int64]bool
// DeliverHooks checks and delivers undelivered hooks.
// FIXME: maybe can use goroutine to shoot a number of them at same time?
func DeliverHooks() {
if isShooting {
queue chan int64
}
func (q *hookQueue) removeRepoID(id int64) {
q.lock.Lock()
defer q.lock.Unlock()
delete(q.repoIDs, id)
}
func (q *hookQueue) addRepoID(id int64) {
q.lock.Lock()
if q.repoIDs[id] {
q.lock.Unlock()
return
}
isShooting = true
defer func() { isShooting = false }()
q.repoIDs[id] = true
q.lock.Unlock()
q.queue <- id
}
tasks := make([]*HookTask, 0, 10)
// AddRepoID adds repository ID to hook delivery queue.
func (q *hookQueue) AddRepoID(id int64) {
go q.addRepoID(id)
}
var HookQueue *hookQueue
func deliverHook(t *HookTask) {
timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
x.Where("is_delivered=?", false).Iterate(new(HookTask),
func(idx int, bean interface{}) error {
t := bean.(*HookTask)
req := httplib.Post(t.Url).SetTimeout(timeout, timeout).
Header("X-Gogs-Delivery", t.Uuid).
Header("X-Gogs-Event", string(t.EventType)).
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
req := httplib.Post(t.Url).SetTimeout(timeout, timeout).
Header("X-Gogs-Delivery", t.Uuid).
Header("X-Gogs-Event", string(t.EventType)).
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
switch t.ContentType {
case JSON:
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
case FORM:
req.Param("payload", t.PayloadContent)
switch t.ContentType {
case JSON:
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
case FORM:
req.Param("payload", t.PayloadContent)
}
t.IsDelivered = true
// FIXME: record response.
switch t.Type {
case GOGS:
{
if resp, err := req.Response(); err != nil {
log.Error(5, "Delivery: %v", err)
} else {
resp.Body.Close()
t.IsSucceed = true
}
t.IsDelivered = true
// FIXME: record response.
switch t.Type {
case GOGS:
{
if _, err := req.Response(); err != nil {
log.Error(5, "Delivery: %v", err)
}
case SLACK:
{
if resp, err := req.Response(); err != nil {
log.Error(5, "Delivery: %v", err)
} else {
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Error(5, "%s", err)
} else {
if string(contents) != "ok" {
log.Error(5, "slack failed with: %s", string(contents))
} else {
t.IsSucceed = true
}
}
case SLACK:
{
if res, err := req.Response(); err != nil {
log.Error(5, "Delivery: %v", err)
} else {
defer res.Body.Close()
contents, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Error(5, "%s", err)
} else {
if string(contents) != "ok" {
log.Error(5, "slack failed with: %s", string(contents))
} else {
t.IsSucceed = true
}
}
}
}
}
}
}
t.Delivered = time.Now().UTC().UnixNano()
if t.IsSucceed {
log.Trace("Hook delivered(%s): %s", t.Uuid, t.PayloadContent)
}
}
// DeliverHooks checks and delivers undelivered hooks.
func DeliverHooks() {
tasks := make([]*HookTask, 0, 10)
x.Where("is_delivered=?", false).Iterate(new(HookTask),
func(idx int, bean interface{}) error {
t := bean.(*HookTask)
deliverHook(t)
tasks = append(tasks, t)
if t.IsSucceed {
log.Trace("Hook delivered(%s): %s", t.Uuid, t.PayloadContent)
}
return nil
})
// Update hook task status.
for _, t := range tasks {
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask(%d): %v", t.Id, err)
log.Error(4, "UpdateHookTask(%d): %v", t.ID, err)
}
}
HookQueue = &hookQueue{
lock: sync.Mutex{},
repoIDs: make(map[int64]bool),
queue: make(chan int64, setting.Webhook.QueueLength),
}
// Start listening on new hook requests.
for repoID := range HookQueue.queue {
HookQueue.removeRepoID(repoID)
tasks = make([]*HookTask, 0, 5)
if err := x.Where("repo_id=? AND is_delivered=?", repoID, false).Find(&tasks); err != nil {
log.Error(4, "Get repository(%d) hook tasks: %v", repoID, err)
continue
}
for _, t := range tasks {
deliverHook(t)
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask(%d): %v", t.ID, err)
}
}
}
}
func InitDeliverHooks() {
go DeliverHooks()
}
+2 -2
View File
@@ -111,7 +111,7 @@ func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _confAppIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x59\x4f\x73\xe3\x46\x76\xbf\xe3\x53\xf4\xd0\x71\x3c\x93\x22\x29\x4a\xf2\xfc\xb1\x6c\x25\xa6\x48\x90\xc2\x8a\xff\x0c\x90\x33\x1e\x4f\xa9\x30\x10\xd0\x24\x61\x81\x68\x0c\x1a\x90\xc4\xad\x1c\xd6\x95\x43\xaa\x72\x4c\xb6\x92\x4b\x0e\xc9\x21\x95\xaa\x24\x9b\x64\x2b\x97\xdd\x4d\xe5\xe4\xca\x7d\xe6\x3b\xb8\xbc\x9b\x6f\x91\xdf\xeb\x06\x48\x50\x23\xcf\x7a\x9d\x6c\xcd\x94\x08\xf4\x9f\xd7\xfd\x5e\xbf\xf7\x7b\xbf\xd7\x78\x8f\x8d\xcc\xa7\xa6\xcd\xd4\x9f\xe1\xb8\x6b\xf5\x9e\xb3\xe9\xa9\xe5\xb0\x9e\x35\x30\x8d\xf7\xd8\x64\x60\xb6\x1d\x93\x0d\xdb\x67\x26\xeb\x9c\xb6\x47\x7d\xd3\x61\xe3\x11\xeb\x8c\x6d\xdb\x74\x26\xe3\x51\xd7\x1a\xf5\x59\x67\xe6\x4c\xc7\x43\x34\x8e\x7a\x56\x5f\xcf\x34\x3e\x66\xed\x24\x61\xb1\xb7\xe2\x2c\x5b\x7a\x19\x93\x4b\x71\x2d\x99\x88\x19\xbf\xe2\xe9\x9a\x25\xde\x02\x1d\x61\x16\x71\xa3\x3d\x99\xb8\xa3\xf6\xd0\x64\xc7\xac\x2f\x16\xf2\x08\x7f\x59\x3f\xcc\x98\xc3\xd3\xab\xd0\xe7\x90\xd4\x59\x7a\x31\x86\xa3\x2d\x9c\xb3\xb5\xc8\x59\x9a\xc7\x2c\x12\xbe\x17\x45\x6b\xc3\x9e\x8d\xdc\x99\x83\xdd\x1f\xb3\x45\x98\x61\xb4\x19\x66\x4b\x9e\xb2\x5a\xc0\xaf\x6a\x75\x56\x4b\x52\x11\xd4\x98\x40\x43\xc6\x65\x86\x96\x80\xcf\xbd\x3c\x82\x2c\xa9\xc7\x28\x09\x50\x9d\x36\x80\x77\xc3\x78\x91\xf2\x44\xc8\x30\x13\xe9\xfa\xdc\xb0\xc7\xe3\x29\x3b\x36\x9c\x8e\x6d\x4d\xa6\xee\xf4\xf9\x84\x86\x5d\x78\x72\x89\x71\x79\x78\x8e\xf5\x46\xf9\xea\x02\xeb\x89\x39\x24\xca\x9c\x4b\xad\xaf\x97\x72\xa5\x33\x0f\x58\x18\x43\x6f\xae\x54\x36\x2c\xc7\x99\x99\xee\xa4\xdd\x87\xdd\xdc\xd1\x6c\x08\x61\xfb\x2d\x88\x92\x50\x96\xa7\xe7\xc6\xc4\x1e\x4f\xc7\x9d\xf1\x00\xed\xcb\x2c\x4b\x8c\xee\x78\xd8\xb6\x46\x78\x53\xea\x2e\x85\xcc\xd4\x8e\xdc\x99\x4d\x43\xde\xbf\x5f\x8e\x7f\x20\x8f\xf6\xf6\xde\xbf\xaf\x87\xe3\xe5\xfd\xfb\xa7\xd3\xe9\xc4\x9d\x8c\xed\xe9\x03\xb9\x67\xa8\x97\x76\xb7\x0b\x2b\x19\x9b\x0e\x08\x38\x6c\xb5\x5a\x50\xa1\x1b\x4a\xef\x22\xe2\xcc\x71\x4e\xd9\x9c\x7b\x59\x8e\xcd\x5f\x2f\x79\xcc\x62\x01\x4d\xae\xbc\x30\xa2\x6e\xa3\x6b\x39\xed\x93\x81\xe9\xd2\xb0\x63\x36\xf7\x22\xc9\x0d\x3c\x97\xc2\x0e\x0e\x2a\xa2\x3a\xdd\x11\x1d\x75\x4c\xda\x17\x67\xb0\x12\x01\x37\xc6\xbd\xde\xc0\x1a\x99\xa5\xc1\xb5\x90\x52\xb0\x3d\x9e\x4d\x4d\xdb\x1d\x8c\xfb\x9b\xae\x8f\x59\x9f\xc7\x3c\xf5\x32\x98\x33\xe3\x89\x3c\x42\xcb\x1f\x30\x3f\x80\x39\xb3\xe5\x5e\x26\xf6\x16\xf0\x99\x3d\x3f\x97\x99\x58\xed\x91\xc9\xa4\x1a\xd0\x54\xed\xcc\xe7\x69\xc6\x1a\xbe\x77\x9c\xa5\x39\x67\x8d\x20\x87\xa0\x50\xc4\xc7\x4f\x1e\x3f\x6a\x2d\x5b\xab\x96\x64\x0d\xb2\xe9\xf1\x6a\x4d\x3f\x4d\x7e\xe3\xad\x92\x88\x37\x7d\xb1\x32\x3e\x86\x9c\x71\xca\xe6\xa9\x58\x31\x8f\x35\x93\xf9\x0d\x9b\x87\x50\x8c\xdf\x24\x22\xcd\x70\xac\xaa\x07\xae\xc6\x9e\x85\x71\x40\xce\x4d\x8b\x85\xf3\xd0\xd7\x7b\x15\xb0\xe1\xfd\x40\x40\x0a\x19\x71\x2e\xd2\x05\xcf\x58\x26\x8a\xf9\x6a\x62\x92\x86\x57\x34\xf8\x92\xaf\x1f\x68\xbd\x44\xc2\x63\x29\x23\x96\x5c\xfa\x72\xff\x80\x35\x60\x3c\x92\xaa\x56\x6f\x88\x3c\x2b\xde\xf8\x8a\x35\x62\x81\x69\xf2\xfb\xcd\xc2\xc8\x72\x12\x75\x48\x7a\x08\xb8\x34\x3a\xa6\x3d\x75\x29\x5e\x61\xee\xaa\x09\xf7\xca\x65\x8c\x33\xf3\xf9\x9d\x03\x0a\x89\x58\x7e\x96\x24\xf0\xfe\x08\x67\x1d\x51\x0c\x64\x1c\x16\x24\xa5\xbc\x38\x80\x15\x60\x6e\x5f\xdb\x8d\xce\x0b\xc3\x2b\xd1\xa7\x4c\x80\x56\x72\x35\x18\x8b\x82\x9f\x9a\xf9\x0d\xf7\x73\x18\xd8\x70\xa6\xed\xa9\xd5\x71\x95\xbf\x4f\xda\x53\xf8\x9c\x46\x95\x88\x4c\x8c\x53\x2c\x16\xed\x7f\x61\x4d\x98\xcc\x13\x32\xab\x61\x8e\x94\x23\xa9\xb6\xad\x0b\x0d\xb0\x99\x30\x5e\x68\xd4\xc1\x51\xe0\x48\xe2\x46\x24\x16\x0b\x1c\x63\x8e\xd0\x93\x75\xe6\x7b\x31\xbb\xe0\xac\xb6\x14\x2b\xae\xe1\x02\x07\x15\xe1\x10\x6b\xc6\xa0\xad\x60\x8e\xa2\x96\xec\x40\x23\x10\xb1\x81\x97\x79\xc0\x01\x7e\x5e\x81\x9c\xd5\x5a\xbe\x8a\x14\xe8\xc0\x9b\x16\x29\x97\x5a\x12\x1a\xc3\x8c\x1f\xa2\x23\xcc\x3e\x90\x84\x60\x29\xf3\x97\x82\xc0\xad\x7b\x52\x62\x8a\x9a\x6b\x9c\x8e\x1d\x0a\xa5\xfd\x83\xc7\xcd\x16\xfe\xed\x1f\x1d\x1e\xb6\x1e\x19\x05\x3c\x92\x4b\x1b\x05\xd6\xa5\x42\x64\xc6\xa4\xed\x38\xcf\xba\xca\x2e\x3d\x5a\xa8\xb2\x6c\x1c\xad\xeb\x8c\x97\x50\xa8\x83\x92\x76\x96\xf2\x57\x79\x98\x16\x2a\x02\x72\xc2\xf9\xba\x31\xcf\xa3\xa8\x86\x48\x1e\x6c\x60\x50\x8f\x2f\xc5\x96\xfb\x57\x52\x0d\x7d\x14\x8c\xf4\x57\x41\xd6\x0c\x2e\x60\x0e\x2f\x58\x85\xf1\xb9\x42\x32\x3f\x4f\xc3\x0c\xd0\x69\x8d\x70\x82\x83\x01\xc2\xb9\x73\x56\x39\x8c\x7b\xf7\x74\x22\xd1\x79\x66\x3a\x66\x67\xa6\x39\x61\xcf\xc7\x33\x9b\x29\xdd\xba\xed\x69\x9b\x39\xed\x9e\x79\xef\x9e\xe1\x98\x1d\xdb\x9c\xba\xf0\x42\x08\xb8\xf7\xde\xa7\xbd\xae\xf9\xcc\xc6\xff\x3f\xfc\xa3\xfb\xe4\x0b\x79\x26\xe8\x18\xe1\xef\x29\x5f\x71\x05\xc3\x81\x87\xa0\x00\x80\x58\x23\xd7\x36\x87\xe6\xf0\x04\x78\xd2\x6d\x3f\x77\x30\xff\xb1\xd1\x19\x8f\xcf\x2c\x53\xa5\x8b\x8a\x49\x5d\xef\x9a\x4b\x3a\xd4\xa2\x7b\x33\xaf\x3a\x26\x8c\xfd\x94\x07\xa1\xb6\x8a\x4d\x49\x4c\x52\x00\x8b\x9b\x35\xf3\x72\x58\x39\xce\x4a\xaf\x5c\x72\x2f\xc0\x46\x54\xea\x43\x40\x90\x7f\xa9\x17\xc3\xa6\x24\xeb\x00\xfd\xed\xf1\xe7\xcf\xdd\xf6\x6c\x7a\x6a\x8e\xe0\xe0\x70\xf2\xf1\x26\x85\x7d\xde\x78\x66\x9e\x50\x57\x83\x1a\x8a\xc4\x00\x47\x39\x37\xda\x9d\xa9\xf5\xd4\Line truncated
var _confAppIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x59\x4f\x93\xdb\x46\x76\xbf\xe3\x53\xb4\xe8\x38\x96\x52\x24\xe7\x9f\xf5\xc7\x63\x4f\x62\x0e\x09\x72\xb0\x22\x09\x1a\x20\x25\xcb\xaa\x29\x08\x03\x34\x49\x78\x40\x34\x84\x06\x66\xc4\xad\x1c\xd6\x95\x43\xaa\x72\x4c\xb6\x92\x4b\x0e\xc9\x21\x95\xaa\x24\x9b\x64\x2b\x97\xdd\x4d\xe5\xe4\xca\x5d\xfa\x0e\x2e\xef\xe6\x5b\xe4\xf7\xba\x01\x12\x1c\x8d\xb5\x5e\x27\x5b\x52\x0d\x81\xfe\xf3\xba\xdf\xeb\xf7\x7e\xef\xf7\x1a\xef\xb1\xb1\xf9\xc4\x74\x98\xfa\x33\xb2\x7b\x56\xff\x19\x9b\x9e\x59\x2e\xeb\x5b\x43\xd3\x78\x8f\x4d\x86\x66\xc7\x35\xd9\xa8\xf3\xd8\x64\xdd\xb3\xce\x78\x60\xba\xcc\x1e\xb3\xae\xed\x38\xa6\x3b\xb1\xc7\x3d\x6b\x3c\x60\xdd\x99\x3b\xb5\x47\x68\x1c\xf7\xad\x81\x9e\x69\x7c\xcc\x3a\x69\xca\x12\x7f\xc5\x59\xbe\xf4\x73\x26\x97\xe2\x5a\x32\x91\x30\x7e\xc5\xb3\x35\x4b\xfd\x05\x3a\xa2\x3c\xe6\x46\x67\x32\xf1\xc6\x9d\x91\xc9\x4e\xd8\x40\x2c\xe4\x31\xfe\xb2\x41\x94\x33\x97\x67\x57\x51\xc0\x21\xa9\xbb\xf4\x13\x0c\x47\x5b\x34\x67\x6b\x51\xb0\xac\x48\x58\x2c\x02\x3f\x8e\xd7\x86\x33\x1b\x7b\x33\x17\xbb\x3f\x61\x8b\x28\xc7\x68\x33\xca\x97\x3c\x63\x8d\x90\x5f\x35\x9a\xac\x91\x66\x22\x6c\x30\x81\x86\x9c\xcb\x1c\x2d\x21\x9f\xfb\x45\x0c\x59\x52\x8f\x51\x12\xa0\x3a\x6d\x00\xef\x86\xf1\x3c\xe3\xa9\x90\x51\x2e\xb2\xf5\xb9\xe1\xd8\xf6\x94\x9d\x18\x6e\xd7\xb1\x26\x53\x6f\xfa\x6c\x42\xc3\x2e\x7c\xb9\xc4\xb8\x22\x3a\xc7\x7a\xe3\x62\x75\x81\xf5\xc4\x1c\x12\x65\xc1\xa5\xd6\xd7\xcf\xb8\xd2\x99\x87\x2c\x4a\xa0\x37\x57\x2a\x1b\x96\xeb\xce\x4c\x6f\xd2\x19\xc0\x6e\xde\x78\x36\x82\xb0\x83\x7d\x88\x92\x50\x96\x67\xe7\xc6\xc4\xb1\xa7\x76\xd7\x1e\xa2\x7d\x99\xe7\xa9\xd1\xb3\x47\x1d\x6b\x8c\x37\xa5\xee\x52\xc8\x5c\xed\xc8\x9b\x39\x34\xe4\xfd\xbb\xd5\xf8\x7b\xf2\x78\x6f\xef\xfd\xbb\x7a\x38\x5e\xde\xbf\x7b\x36\x9d\x4e\xbc\x89\xed\x4c\xef\xc9\x3d\x43\xbd\x74\x7a\x3d\x58\xc9\xd8\x74\x40\xc0\xd1\xfe\xfe\x3e\x54\xe8\x45\xd2\xbf\x88\x39\x73\xdd\x33\x36\xe7\x7e\x5e\x60\xf3\xd7\x4b\x9e\xb0\x44\x40\x93\x2b\x3f\x8a\xa9\xdb\xe8\x59\x6e\xe7\x74\x68\x7a\x34\xec\x84\xcd\xfd\x58\x72\x03\xcf\x95\xb0\xc3\xc3\x9a\xa8\x6e\x6f\x4c\x47\x9d\x90\xf6\xe5\x19\xac\x44\xc8\x0d\xbb\xdf\x1f\x5a\x63\xb3\x32\xb8\x16\x52\x09\x76\xec\xd9\xd4\x74\xbc\xa1\x3d\xd8\x74\x7d\xcc\x06\x3c\xe1\x99\x9f\xc3\x9c\x39\x4f\xe5\x31\x5a\xfe\x80\x05\x21\xcc\x99\x2f\xf7\x72\xb1\xb7\x80\xcf\xec\x05\x85\xcc\xc5\x6a\x8f\x4c\x26\xd5\x80\xb6\x6a\x67\x01\xcf\x72\xd6\x0a\xfc\x93\x3c\x2b\x38\x6b\x85\x05\x04\x45\x22\x39\x79\xf4\xf0\xc1\xfe\x72\x7f\xb5\x2f\x59\x8b\x6c\x7a\xb2\x5a\xd3\x4f\x9b\xbf\xf2\x57\x69\xcc\xdb\x81\x58\x19\x1f\x43\x8e\x9d\xb1\x79\x26\x56\xcc\x67\xed\x74\xfe\x8a\xcd\x23\x28\xc6\x5f\xa5\x22\xcb\x71\xac\xaa\x07\xae\xc6\x9e\x46\x49\x48\xce\x4d\x8b\x45\xf3\x28\xd0\x7b\x15\xb0\xe1\xdd\x50\x40\x0a\x19\x71\x2e\xb2\x05\xcf\x59\x2e\xca\xf9\x6a\x62\x9a\x45\x57\x34\xf8\x92\xaf\xef\x69\xbd\x44\xca\x13\x29\x63\x96\x5e\x06\xf2\xe0\x90\xb5\x60\x3c\x92\xaa\x56\x6f\x89\x22\x2f\xdf\xf8\x8a\xb5\x12\x81\x69\xf2\xfb\xcd\xc2\xc8\x6a\x12\x75\x48\x7a\x08\xb9\x34\xba\xa6\x33\xf5\x28\x5e\x61\xee\xba\x09\xf7\xaa\x65\x8c\xc7\xe6\xb3\x5b\x07\x94\x12\xb1\xfc\x2c\x4d\xe1\xfd\x31\xce\x3a\xa6\x18\xc8\x39\x2c\x48\x4a\xf9\x49\x08\x2b\xc0\xdc\x81\xb6\x1b\x9d\x17\x86\xd7\xa2\x4f\x99\x00\xad\xe4\x6a\x30\x16\x05\x3f\x35\xf3\x57\x3c\x28\x60\x60\xc3\x9d\x76\xa6\x56\xd7\x53\xfe\x3e\xe9\x4c\xe1\x73\x1a\x55\x62\x32\x31\x4e\xb1\x5c\x74\xf0\x85\x35\x61\xb2\x48\xc9\xac\x86\x39\x56\x8e\xa4\xda\xb6\x2e\x34\xc4\x66\xa2\x64\xa1\x51\x07\x47\x81\x23\x49\x5a\xb1\x58\x2c\x70\x8c\x05\x42\x4f\x36\x59\xe0\x27\xec\x82\xb3\xc6\x52\xac\xb8\x86\x0b\x1c\x54\x8c\x43\x6c\x18\xc3\x8e\x82\x39\x8a\x5a\xb2\x03\x8d\x40\xc4\x86\x7e\xee\x03\x07\xf8\x79\x0d\x72\x56\x6b\xf9\x32\x56\xa0\x03\x6f\x5a\x64\x5c\x6a\x49\x68\x8c\x72\x7e\x84\x8e\x28\xff\x40\x12\x82\x65\x2c\x58\x0a\x02\xb7\xde\x69\x85\x29\x6a\xae\x71\x66\xbb\x14\x4a\x07\x87\x0f\xdb\xfb\xf8\x77\x70\x7c\x74\xb4\xff\xc0\x28\xe1\x91\x5c\xda\x28\xb1\x2e\x13\x22\x37\x26\x1d\xd7\x7d\xda\x53\x76\xe9\xd3\x42\xb5\x65\x93\x78\xdd\x64\xbc\x82\x42\x1d\x94\xb4\xb3\x8c\xbf\x2c\xa2\xac\x54\x11\x90\x13\xcd\xd7\xad\x79\x11\xc7\x0d\x44\xf2\x70\x03\x83\x7a\x7c\x25\xb6\xda\xbf\x92\x6a\xe8\xa3\x60\xa4\xbf\x0a\xb2\x76\x78\x01\x73\xf8\xe1\x2a\x4a\xce\x15\x92\x05\x45\x16\xe5\x80\x4e\x6b\x8c\x13\x1c\x0e\x11\xce\xdd\xc7\xb5\xc3\xb8\x73\x47\x27\x12\x9d\x67\xa6\x36\x7b\x6c\x9a\x13\xf6\xcc\x9e\x39\x4c\xe9\xd6\xeb\x4c\x3b\xcc\xed\xf4\xcd\x3b\x77\x0c\xd7\xec\x3a\xe6\xd4\x83\x17\x42\xc0\x9d\xf7\x3e\xed\xf7\xcc\xa7\x0e\xfe\xff\xe1\x1f\xdd\x25\x5f\x28\x72\x41\xc7\x08\x7f\xcf\xf8\x8a\x2b\x18\x0e\x7d\x04\x05\x00\xc4\x1a\x7b\x8e\x39\x32\x47\xa7\xc0\x93\x5e\xe7\x99\x8b\xf9\x0f\x8d\xae\x6d\x3f\xb6\x4c\x95\x2e\x6a\x26\xf5\xfc\x6b\x2e\xe9\x50\xcb\xee\xcd\xbc\xfa\x98\x28\x09\x32\x1e\x46\xda\x2a\x0e\x25\x31\x49\x01\x2c\x5e\xad\x99\x5f\xc0\xca\x49\x5e\x79\xe5\x92\xfb\x21\x36\xa2\x52\x1f\x02\x82\xfc\x4b\xbd\x18\x0e\x25\x59\x17\xe8\xef\xd8\x9f\x3f\xf3\x3a\xb3\xe9\x99\x39\x86\x83\xc3\xc9\xed\x4d\x0a\xfb\xbc\xf5\xd4\x3c\xa5\xae\x16\x35\x94\x89\x01\x8e\x72\x6e\x74\xba\x53\xeb\x89\xe9\Line truncated
func confAppIniBytes() ([]byte, error) {
return bindataRead(
@@ -126,7 +126,7 @@ func confAppIni() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "conf/app.ini", size: 8970, mode: os.FileMode(420), modTime: time.Unix(1437763990, 0)}
info := bindataFileInfo{name: "conf/app.ini", size: 8965, mode: os.FileMode(420), modTime: time.Unix(1437828956, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
-1
View File
@@ -15,7 +15,6 @@ var c = New()
func NewCronContext() {
c.AddFunc("Update mirrors", "@every 1h", models.MirrorUpdate)
c.AddFunc("Deliver hooks", fmt.Sprintf("@every %dm", setting.Webhook.TaskInterval), models.DeliverHooks)
if setting.Git.Fsck.Enable {
c.AddFunc("Repository health check", fmt.Sprintf("@every %dh", setting.Git.Fsck.Interval), models.GitFsck)
}
+2 -2
View File
@@ -76,7 +76,7 @@ var (
// Webhook settings.
Webhook struct {
TaskInterval int
QueueLength int
DeliverTimeout int
SkipTLSVerify bool
}
@@ -555,7 +555,7 @@ func newNotifyMailService() {
func newWebhookService() {
sec := Cfg.Section("webhook")
Webhook.TaskInterval = sec.Key("TASK_INTERVAL").MustInt(1)
Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
}
+1
View File
@@ -68,6 +68,7 @@ func GlobalInit() {
models.HasEngine = true
cron.NewCronContext()
models.InitDeliverHooks()
log.NewGitLogger(path.Join(setting.LogRootPath, "http.log"))
}
if models.EnableSQLite3 {
+4 -1
View File
@@ -190,7 +190,10 @@ func Http(ctx *middleware.Context) {
refName := fields[2]
// FIXME: handle error.
models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id)
if err = models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id); err == nil {
models.HookQueue.AddRepoID(repo.Id)
}
}
lastLine = lastLine + size
} else {
+4
View File
@@ -634,3 +634,7 @@ func GitHooksEditPost(ctx *middleware.Context) {
}
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks/git")
}
func TriggerHook(ctx *middleware.Context) {
models.HookQueue.AddRepoID(ctx.Repo.Repository.Id)
}
+1 -1
View File
@@ -1 +1 @@
0.6.2.0725 Beta
0.6.3.0725 Beta