]> Sergey Matveev's repositories - sgblog.git/commitdiff
Work with From without name
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2020 20:25:33 +0000 (23:25 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2020 20:25:33 +0000 (23:25 +0300)
cmd/sgblog-comment-add/main.go

index 728f34e2fe17e359cb2b3096a3864908932bb282..b967d949d90bfd399d8f71db02b8e7975c6b9e3f 100644 (file)
@@ -80,7 +80,13 @@ func main() {
                os.Exit(0)
        }
        fromCols := strings.Fields(from)
-       from = strings.Join(fromCols[:len(fromCols)-1], " ")
+       if len(fromCols) == 1 {
+               if idx := strings.Index(from, "@"); idx != -1 {
+                       from = strings.Trim(from[:idx], "<>")
+               }
+       } else {
+               from = strings.Join(fromCols[:len(fromCols)-1], " ")
+       }
 
        cmd := exec.Command(
                *gitCmd, "--git-dir", *gitDir,