From 923844b981ffa744033bd20dcb2124a8b7fcf057 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 20 Mar 2025 18:00:48 +0300 Subject: [PATCH] fix(hooks): pre and post hooks now receive the full input line This fixes an issue where the pre and post hooks won't receive the full input lines when they're split. This is because the scanner is used to read the input line by line, and the scanner strips the newline character from the input. This change adds the newline character back to the input line before passing it to the pre and post hooks. Fixes: https://github.com/charmbracelet/soft-serve/issues/680 --- cmd/soft/hook/hook.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soft/hook/hook.go b/cmd/soft/hook/hook.go index 43718ed22042e0c9d5c6b84cb9ac1488b3c724eb..b12938af10e66b8741347d3f9e69a3908e7e3daa 100644 --- a/cmd/soft/hook/hook.go +++ b/cmd/soft/hook/hook.go @@ -80,6 +80,7 @@ var ( scanner := bufio.NewScanner(stdin) for scanner.Scan() { buf.Write(scanner.Bytes()) + buf.WriteByte('\n') fields := strings.Fields(scanner.Text()) if len(fields) != 3 { return fmt.Errorf("invalid hook input: %s", scanner.Text())