From 394b2c71490744c0b50fbdf59de17768ce6c725e Mon Sep 17 00:00:00 2001 From: ChrisERo Date: Sat, 15 Jan 2022 15:19:31 -0500 Subject: [PATCH] fix: perform hook null check before waiting Last 2 commits introduced fatal null-pointer exception when waiting on HookRunner object when not set, e.g. waiting for WebhookRunner when no webhook is defined. Fixed bug and got test_e2e.sh to run successfully. --- cmd/git-sync/main.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/git-sync/main.go b/cmd/git-sync/main.go index 408798a..895a6e1 100644 --- a/cmd/git-sync/main.go +++ b/cmd/git-sync/main.go @@ -638,13 +638,17 @@ func main() { // Assumes that if hook channels are not nil, they will have at // least one value before getting closed exitCode := 0 // is 0 if all hooks succeed, else is 1 - if err = exechookRunner.WaitForCompletion(); err != nil { - log.Error(err, "exechook completed with error") - exitCode = 1 + if exechookRunner != nil { + if err = exechookRunner.WaitForCompletion(); err != nil { + log.Error(err, "exechook completed with error") + exitCode = 1 + } } - if err = webhookRunner.WaitForCompletion(); err != nil { - log.Error(err, "webhook completed with error") - exitCode = 1 + if webhookRunner != nil { + if err = webhookRunner.WaitForCompletion(); err != nil { + log.Error(err, "webhook completed with error") + exitCode = 1 + } } log.DeleteErrorFile() os.Exit(exitCode)