Skip to content

Commit 824dc67

Browse files
authored
chore: Add option to disable automatic commits and skip verification. (#13)
- Add a `disableAutoCommit` flag to the `commit` command - Add the `--no-verify` flag to the `commit` command - Modify the `prepare-commit-msg` file to use the `--disbaleCommit` flag when invoking the `codegpt commit` command fix #12
1 parent 20c7802 commit 824dc67

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

cmd/commit.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ import (
1818
var (
1919
commitLang string
2020
commitModel string
21+
22+
// disbale auot commit in Hook mode
23+
disableAutoCommit bool
2124
)
2225

2326
func init() {
2427
commitCmd.PersistentFlags().StringP("file", "f", ".git/COMMIT_EDITMSG", "commit message file")
28+
commitCmd.PersistentFlags().BoolVar(&disableAutoCommit, "disbaleCommit", false, "disable auto commit message")
2529
commitCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-3.5-turbo", "select openai model")
2630
commitCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
2731
_ = viper.BindPFlag("output.file", commitCmd.PersistentFlags().Lookup("file"))
@@ -154,6 +158,10 @@ var commitCmd = &cobra.Command{
154158
return err
155159
}
156160

161+
if disableAutoCommit {
162+
return nil
163+
}
164+
157165
// git commit automatically
158166
color.Cyan("Git record changes to the repository")
159167
output, err := g.Commit(viper.GetString("output.file"))

git/git.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (c *Command) hookPath() *exec.Cmd {
7878
func (c *Command) commit(val string) *exec.Cmd {
7979
args := []string{
8080
"commit",
81+
"--no-verify",
8182
"--file",
8283
val,
8384
}

git/templates/prepare-commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
codegpt commit --file $1
3+
codegpt commit --file $1 --disbaleCommit

0 commit comments

Comments
 (0)