Skip to content

Commit c2da943

Browse files
committed
Fix #718
1 parent 7bb6808 commit c2da943

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

internal/hook/hook.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ func (r Rules) Evaluate(req *Request) (bool, error) {
824824
return r.Match.Evaluate(req)
825825
}
826826

827-
return false, nil
827+
return true, nil
828828
}
829829

830830
// AndRule will evaluate to true if and only if all of the ChildRules evaluate to true

internal/hook/hook_test.go

+16-15
Original file line numberDiff line numberDiff line change
@@ -351,20 +351,21 @@ func TestHookExtractCommandArguments(t *testing.T) {
351351
// we test both cases where the name of the data is used as the name of the
352352
// env key & the case where the hook definition sets the env var name to a
353353
// fixed value using the envname construct like so::
354-
// [
355-
// {
356-
// "id": "push",
357-
// "execute-command": "bb2mm",
358-
// "command-working-directory": "/tmp",
359-
// "pass-environment-to-command":
360-
// [
361-
// {
362-
// "source": "entire-payload",
363-
// "envname": "PAYLOAD"
364-
// },
365-
// ]
366-
// }
367-
// ]
354+
//
355+
// [
356+
// {
357+
// "id": "push",
358+
// "execute-command": "bb2mm",
359+
// "command-working-directory": "/tmp",
360+
// "pass-environment-to-command":
361+
// [
362+
// {
363+
// "source": "entire-payload",
364+
// "envname": "PAYLOAD"
365+
// },
366+
// ]
367+
// }
368+
// ]
368369
var hookExtractCommandArgumentsForEnvTests = []struct {
369370
exec string
370371
args []Argument
@@ -596,7 +597,7 @@ var andRuleTests = []struct {
596597
[]byte{},
597598
true, false,
598599
},
599-
{"empty rule", AndRule{{}}, nil, nil, nil, nil, false, false},
600+
{"empty rule", AndRule{{}}, nil, nil, nil, nil, true, false},
600601
// failures
601602
{
602603
"invalid rule",

webhook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/json"
66
"flag"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"log"
1010
"net"
1111
"net/http"
@@ -172,7 +172,7 @@ func main() {
172172
}
173173

174174
if !*verbose {
175-
log.SetOutput(ioutil.Discard)
175+
log.SetOutput(io.Discard)
176176
}
177177

178178
// Create pidfile
@@ -379,7 +379,7 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
379379
isMultipart := strings.HasPrefix(req.ContentType, "multipart/form-data;")
380380

381381
if !isMultipart {
382-
req.Body, err = ioutil.ReadAll(r.Body)
382+
req.Body, err = io.ReadAll(r.Body)
383383
if err != nil {
384384
log.Printf("[%s] error reading the request body: %+v\n", req.ID, err)
385385
}
@@ -608,7 +608,7 @@ func handleHook(h *hook.Hook, r *hook.Request) (string, error) {
608608
}
609609

610610
for i := range files {
611-
tmpfile, err := ioutil.TempFile(h.CommandWorkingDirectory, files[i].EnvName)
611+
tmpfile, err := os.CreateTemp(h.CommandWorkingDirectory, files[i].EnvName)
612612
if err != nil {
613613
log.Printf("[%s] error creating temp file [%s]", r.ID, err)
614614
continue

0 commit comments

Comments
 (0)