From 7eb781908b7141de98d6845d711fbcc879c0a2d7 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 14 Jan 2020 23:25:18 +0300 Subject: [PATCH] sgblog-comment-add -dryrun option --- cmd/sgblog-comment-add/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/sgblog-comment-add/main.go b/cmd/sgblog-comment-add/main.go index b52e68a..728f34e 100644 --- a/cmd/sgblog-comment-add/main.go +++ b/cmd/sgblog-comment-add/main.go @@ -44,6 +44,7 @@ func main() { 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") flag.Parse() uid := syscall.Geteuid() if err := syscall.Setuid(uid); err != nil { @@ -107,6 +108,11 @@ func main() { strings.Join(lines, "\n"), ))) + if *dryRun { + fmt.Print(buf.String()) + os.Exit(0) + } + cmd = exec.Command( *gitCmd, "--git-dir", *gitDir, "notes", "--ref", *notesRef, "add", -- 2.48.1