Skip to content

fix: fatal: cannot lock ref 'HEAD' issue #191 #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (

defaultTimeout = 30 * time.Second
noConfirm = false
noCommit = false
)

func init() {
Expand All @@ -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"))
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion git/templates/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -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