From 486c564fe57aa8d15220c0b1845d2b4560e7ed84 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Mon, 4 Jul 2022 00:46:40 +0700 Subject: [PATCH] fix: use exec cmd instead of go-git --- internal/cli/action_generate.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/cli/action_generate.go b/internal/cli/action_generate.go index a076369..0b5de02 100644 --- a/internal/cli/action_generate.go +++ b/internal/cli/action_generate.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "os/exec" "path/filepath" "strings" "time" @@ -20,7 +21,7 @@ import ( "golang.org/x/mod/semver" ) -const autoCommitMessageTemplate = "chore(changelog): generate version %s" +const autoCommitMessageTemplate = "chore(changelog): generate %s" var ( ErrUnknownFiletype = errors.New("unknown filetype") @@ -72,9 +73,21 @@ func (a *action) RunGenerate(c *cli.Context) error { if a.flags.autoCommit { commitMsg := fmt.Sprintf(autoCommitMessageTemplate, version) - if err := repo.Commit(commitMsg, finalOutput); err != nil { + // TODO: disable until https://github.com/go-git/go-git/issues/180 is fixed + // if err := repo.Commit(commitMsg, finalOutput); err != nil { + // return err + // } + cmdOutput, err := exec.CommandContext(c.Context, "git", "add", finalOutput).CombinedOutput() + if err != nil { return err } + a.log("git add output:\n%s", cmdOutput) + + cmdOutput, err = exec.CommandContext(c.Context, "git", "commit", "-m", commitMsg).CombinedOutput() + if err != nil { + return err + } + a.log("git commit output:\n%s", cmdOutput) } return nil