-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cmd): add git hook management feature.
- Add a new `hookCmd` command to install and uninstall git hooks - Remove `log` library import from `cmd/config.go` - Replace `log.Fatal` calls with `errors.New` returns in `cmd/config.go` - Add a `hookPath` function to get the git hook path - Add a new `prepare-commit-msg` file to the `hook/templates` directory.
- Loading branch information
Showing
5 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/appleboy/CodeGPT/hook" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var hookCmd = &cobra.Command{ | ||
Use: "hook", | ||
Short: "install/uninstall git prepare-commit-msg hook", | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if args[0] != "install" && args[0] != "uninstall" { | ||
return errors.New("only support install or uninstall command") | ||
} | ||
|
||
switch args[0] { | ||
case "install": | ||
return hook.Install() | ||
case "uninstall": | ||
return hook.Uninstall() | ||
} | ||
|
||
return nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
codegpt commit --file $1 |