diff --git a/cmd/commit.go b/cmd/commit.go index 9b71bd8..554e63a 100644 --- a/cmd/commit.go +++ b/cmd/commit.go @@ -40,6 +40,7 @@ var ( defaultTimeout = 30 * time.Second noConfirm = false + noCommit = false ) func init() { @@ -64,6 +65,8 @@ func init() { "show prompt only, don't send request to openai") commitCmd.PersistentFlags().BoolVar(&noConfirm, "no_confirm", false, "skip confirmation prompt") + commitCmd.PersistentFlags().BoolVar(&noCommit, "no_commit", false, + "skip commit") _ = viper.BindPFlag("output.file", commitCmd.PersistentFlags().Lookup("file")) } @@ -306,6 +309,10 @@ var commitCmd = &cobra.Command{ } } + if noCommit { + return nil + } + // git commit automatically color.Cyan("Git record changes to the repository") output, err := g.Commit(commitMessage) diff --git a/git/templates/prepare-commit-msg b/git/templates/prepare-commit-msg index 4da9b71..bb2747d 100755 --- a/git/templates/prepare-commit-msg +++ b/git/templates/prepare-commit-msg @@ -1,5 +1,5 @@ #!/usr/bin/env bash if [[ "$2" != "message" && "$2" != "commit" ]]; then - codegpt commit --file $1 --preview --no_confirm + codegpt commit --file $1 --preview --no_confirm --no_commit fi