"fmt"
"io/ioutil"
"log"
+ "mime"
"net/mail"
"os"
"os/exec"
if len(body) == 0 {
log.Fatal("no body")
}
+ from, err = new(mime.WordDecoder).DecodeHeader(from)
+ if err != nil {
+ log.Fatal(err)
+ }
subj = strings.TrimPrefix(subj, "Re: ")
if h, err := hex.DecodeString(subj); err != nil || len(h) != sha1.Size {
note = bytes.TrimRight(note, "\r\n")
// Remove trailing whitespaces, because git-notes-add will remove
- // them anyway, and we have to know exact bytes count
+ // them anyway, and we have to know exact bytes count. Also convert
+ // all tabs into spaces
lines := strings.Split(string(body), "\n")
for i, line := range lines {
- lines[i] = strings.TrimRight(line, " \r")
+ line = strings.ReplaceAll(line, " ", " ")
+ line = strings.TrimRight(line, " \r")
+ lines[i] = line
}
for lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]