|
8 | 8 | "context"
|
9 | 9 | "fmt"
|
10 | 10 | "os"
|
11 |
| - "path" |
12 | 11 | "path/filepath"
|
13 | 12 | "sort"
|
14 | 13 | "strings"
|
@@ -55,26 +54,23 @@ func LoadRepoConfig() {
|
55 | 54 | for i, t := range types {
|
56 | 55 | files, err := options.Dir(t)
|
57 | 56 | if err != nil {
|
58 |
| - log.Fatal("Failed to get %s files: %v", t, err) |
| 57 | + log.Fatal("Failed to list %s files: %v", t, err) |
59 | 58 | }
|
60 |
| - customPath := path.Join(setting.CustomPath, "options", t) |
61 |
| - isDir, err := util.IsDir(customPath) |
62 |
| - if err != nil { |
63 |
| - log.Fatal("Failed to get custom %s files: %v", t, err) |
64 |
| - } |
65 |
| - if isDir { |
| 59 | + customPath := filepath.Join(setting.CustomPath, "options", t) |
| 60 | + if isDir, err := util.IsDir(customPath); err != nil { |
| 61 | + log.Fatal("Failed to check custom %s dir: %v", t, err) |
| 62 | + } else if isDir { |
66 | 63 | customFiles, err := util.StatDir(customPath)
|
67 | 64 | if err != nil {
|
68 |
| - log.Fatal("Failed to get custom %s files: %v", t, err) |
| 65 | + log.Fatal("Failed to list custom %s files: %v", t, err) |
69 | 66 | }
|
70 |
| - |
71 | 67 | for _, f := range customFiles {
|
72 | 68 | stat, err := os.Stat(filepath.Join(customPath, f))
|
73 | 69 | if err != nil {
|
74 |
| - log.Fatal("Failed to stat custom %s files: %v", t, err) |
| 70 | + log.Fatal("Failed to stat custom %s file %q: %v", t, f, err) |
75 | 71 | }
|
| 72 | + // give end users a chance to hide builtin options if they put an empty file in their custom directory |
76 | 73 | if stat.Size() == 0 {
|
77 |
| - // it's good to give end users a chance to hide builtin options if they put an empty file in their custom directory |
78 | 74 | files = util.SliceRemoveAllFunc(files, func(s string) bool { return strings.EqualFold(s, f) })
|
79 | 75 | } else if !util.SliceContainsString(files, f, true) {
|
80 | 76 | files = append(files, f)
|
|
0 commit comments