923844b981ffa744033bd20dcb2124a8b7fcf057

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

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

Diff

 1diff --git a/cmd/soft/hook/hook.go b/cmd/soft/hook/hook.go
 2index 43718ed22042e0c9d5c6b84cb9ac1488b3c724eb..b12938af10e66b8741347d3f9e69a3908e7e3daa 100644
 3--- a/cmd/soft/hook/hook.go
 4+++ b/cmd/soft/hook/hook.go
 5@@ -80,6 +80,7 @@ var (
 6 			scanner := bufio.NewScanner(stdin)
 7 			for scanner.Scan() {
 8 				buf.Write(scanner.Bytes())
 9+				buf.WriteByte('\n')
10 				fields := strings.Fields(scanner.Text())
11 				if len(fields) != 3 {
12 					return fmt.Errorf("invalid hook input: %s", scanner.Text())