X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=cmd%2Fsgblog-comment-add%2Fmain.go;h=8b46c555929ca3a17ddf06e19486b30d5e957e90;hb=83b8b5276a384fe21b7db667d08789074661732d;hp=8bae15fdc1dda25f9a92c5f35b1505ebb1eb5d6f;hpb=af77745bd0429428851b0f752984932d3e1188a8;p=sgblog.git diff --git a/cmd/sgblog-comment-add/main.go b/cmd/sgblog-comment-add/main.go index 8bae15f..8b46c55 100644 --- a/cmd/sgblog-comment-add/main.go +++ b/cmd/sgblog-comment-add/main.go @@ -35,16 +35,20 @@ import ( "time" "go.cypherpunks.ru/netstring/v2" + "go.stargrave.org/sgblog" ) -const WhenFmt = "2006-01-02 15:04:05Z07:00" - func main() { gitCmd := flag.String("git-cmd", "/usr/local/bin/git", "Path to git executable") gitDir := flag.String("git-dir", "", "Path to .git repository") notesRef := flag.String("ref", "comments", "notes reference name") umask := flag.String("umask", "027", "umask value") dryRun := flag.Bool("dryrun", false, "Show comment, do not add") + committerEmail := flag.String( + "committer-email", + "comment@blog.example.com", + "Git committer's email", + ) flag.Parse() uid := syscall.Geteuid() if err := syscall.Setuid(uid); err != nil { @@ -111,7 +115,7 @@ func main() { w.WriteChunk([]byte(fmt.Sprintf( "From: %s\nDate: %s\n\n%s", from, - time.Now().UTC().Format(WhenFmt), + time.Now().UTC().Format(sgblog.WhenFmt), strings.Join(lines, "\n"), ))) @@ -125,6 +129,13 @@ func main() { "notes", "--ref", *notesRef, "add", "-F", "-", "-f", subj, ) + cmd.Env = append( + cmd.Env, + "GIT_AUTHOR_NAME=SGBlog "+sgblog.Version, + "GIT_AUTHOR_EMAIL="+*committerEmail, + "GIT_COMMITTER_NAME=SGBlog "+sgblog.Version, + "GIT_COMMITTER_EMAIL="+*committerEmail, + ) cmd.Stdin = buf if err = cmd.Run(); err != nil { log.Fatal(err)