fix: use exec cmd instead of go-git

main
sudo pacman -Syu 2022-07-04 00:46:40 +07:00 committed by sudo pacman -Syu
parent ae9371b193
commit 486c564fe5
1 changed files with 15 additions and 2 deletions

View File

@ -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