From 92e84ca5828b5944ed24668818543cb8df477484 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 29 Mar 2026 22:39:24 +0100 Subject: [PATCH] skip pre/post hooks for completion command --- cmd/root.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 7216575..b0a481a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,10 @@ It allows you to add, list, and delete patterns from the exclude file easily. This tool is particularly useful for developers who want to keep their repository clean by excluding certain files or directories from version control.`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + if cmd.Name() == "completion" { + return nil + } + if _, err := os.Stat(".git"); os.IsNotExist(err) { return fmt.Errorf("this command must be run in a Git repository") } @@ -42,6 +46,10 @@ by excluding certain files or directories from version control.`, return nil }, PersistentPostRunE: func(cmd *cobra.Command, args []string) error { + if cmd.Name() == "completion" { + return nil + } + if ctx, ok := ContextObjectFromContext(cmd.Context()); ok { defer ctx.File.Close() } else {