added support for x-hub-signature

This commit is contained in:
Adnan Hajdarevic 2015-01-20 18:57:16 +01:00
parent 450852e1be
commit 3c4c025233
2 changed files with 22 additions and 17 deletions

View file

@ -45,6 +45,10 @@ func (h *Hook) UnmarshalJSON(j []byte) error {
h.Cwd = v.(string)
}
if v, ok := m["secret"]; ok {
h.Secret = v.(string)
}
if v, ok := m["trigger-rule"]; ok {
rule := v.(map[string]interface{})
@ -126,7 +130,7 @@ func New(hookFile string) (*Hooks, error) {
func (h *Hooks) Match(id string, params interface{}) *Hook {
for i := range h.list {
if h.list[i].ID == id {
if h.list[i].Rule != nil && h.list[i].Rule.Evaluate(params) {
if h.list[i].Rule == nil || (h.list[i].Rule != nil && h.list[i].Rule.Evaluate(params)) {
return &h.list[i]
}
}