]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog-comment-add/main.go
Fix tabs issues in comments
[sgblog.git] / cmd / sgblog-comment-add / main.go
index 840c3782d0a9a5f3acce3c58cc5f0242d7cff6cb..719431b37318c1576402c7528531e14b50d7fbdf 100644 (file)
@@ -106,10 +106,13 @@ func main() {
        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]