mirror of
https://github.com/onyx-and-iris/exclude.git
synced 2026-04-16 14:13:39 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b956f58f5e | |||
| bfa3314ad3 | |||
| 92e84ca582 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
|||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
bin/
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|||||||
10
cmd/root.go
10
cmd/root.go
@@ -28,6 +28,11 @@ 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
|
This tool is particularly useful for developers who want to keep their repository clean
|
||||||
by excluding certain files or directories from version control.`,
|
by excluding certain files or directories from version control.`,
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if strings.HasPrefix(cmd.CommandPath(), "exclude completion") ||
|
||||||
|
strings.HasPrefix(cmd.CommandPath(), "exclude help") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(".git"); os.IsNotExist(err) {
|
if _, err := os.Stat(".git"); os.IsNotExist(err) {
|
||||||
return fmt.Errorf("this command must be run in a Git repository")
|
return fmt.Errorf("this command must be run in a Git repository")
|
||||||
}
|
}
|
||||||
@@ -42,6 +47,11 @@ by excluding certain files or directories from version control.`,
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if strings.HasPrefix(cmd.CommandPath(), "exclude completion") ||
|
||||||
|
strings.HasPrefix(cmd.CommandPath(), "exclude help") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if ctx, ok := ContextObjectFromContext(cmd.Context()); ok {
|
if ctx, ok := ContextObjectFromContext(cmd.Context()); ok {
|
||||||
defer ctx.File.Close()
|
defer ctx.File.Close()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user