MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / UninstallHook

Method UninstallHook

git/git.go:245–260  ·  view source on GitHub ↗

UninstallHook removes the prepare-commit-msg hook if it exists. It retrieves the hooks directory path, checks if the hook file exists, and removes the hook file.

(ctx context.Context)

Source from the content-addressed store, hash-verified

243// UninstallHook removes the prepare-commit-msg hook if it exists.
244// It retrieves the hooks directory path, checks if the hook file exists, and removes the hook file.
245func (c *Command) UninstallHook(ctx context.Context) error {
246 hookPath, err := c.hookPath(ctx).Output()
247 if err != nil {
248 return err
249 }
250
251 target := path.Join(strings.TrimSpace(string(hookPath)), HookPrepareCommitMessageTemplate)
252 exists, err := file.IsFile(target)
253 if err != nil {
254 return err
255 }
256 if !exists {
257 return errors.New("hook file prepare-commit-msg is not exist")
258 }
259 return os.Remove(target)
260}
261
262// New creates a new Command object with the provided options.
263// It applies each option to the config object and initializes the Command object with the configurations.

Callers 1

hook.goFile · 0.80

Calls 1

hookPathMethod · 0.95

Tested by

no test coverage detected