|
7 | 7 | "io" |
8 | 8 | "path/filepath" |
9 | 9 |
|
| 10 | + "github.com/Veraticus/cc-tools/internal/shared" |
10 | 11 | "github.com/Veraticus/cc-tools/internal/skipregistry" |
11 | 12 | ) |
12 | 13 |
|
@@ -101,31 +102,43 @@ func checkSkipsFromInput(ctx context.Context, stdinData []byte, debug bool, stde |
101 | 102 | } |
102 | 103 |
|
103 | 104 | // Get directory from file path |
104 | | - dir := filepath.Dir(filePath) |
| 105 | + fileDir := filepath.Dir(filePath) |
| 106 | + |
| 107 | + // Find the project root - same as we do for discovering lint/test commands |
| 108 | + projectRoot, err := shared.FindProjectRoot(fileDir, nil) |
| 109 | + if err != nil { |
| 110 | + if debug { |
| 111 | + _, _ = fmt.Fprintf(stderr, "Failed to find project root: %v\n", err) |
| 112 | + } |
| 113 | + // If we can't find project root, check the file's directory as fallback |
| 114 | + projectRoot = fileDir |
| 115 | + } |
105 | 116 |
|
106 | 117 | // Convert to absolute path |
107 | | - absDir, err := filepath.Abs(dir) |
| 118 | + absProjectRoot, err := filepath.Abs(projectRoot) |
108 | 119 | if err != nil { |
109 | 120 | if debug { |
110 | 121 | _, _ = fmt.Fprintf(stderr, "Failed to get absolute path: %v\n", err) |
111 | 122 | } |
112 | 123 | return false, false |
113 | 124 | } |
114 | 125 |
|
115 | | - // Check skip registry |
| 126 | + // Check skip registry for the project root |
116 | 127 | storage := skipregistry.DefaultStorage() |
117 | 128 | registry := skipregistry.NewRegistry(storage) |
118 | 129 |
|
119 | | - skipLint, _ := registry.IsSkipped(ctx, skipregistry.DirectoryPath(absDir), skipregistry.SkipTypeLint) |
120 | | - skipTest, _ := registry.IsSkipped(ctx, skipregistry.DirectoryPath(absDir), skipregistry.SkipTypeTest) |
| 130 | + skipLint, _ := registry.IsSkipped(ctx, skipregistry.DirectoryPath(absProjectRoot), skipregistry.SkipTypeLint) |
| 131 | + skipTest, _ := registry.IsSkipped(ctx, skipregistry.DirectoryPath(absProjectRoot), skipregistry.SkipTypeTest) |
121 | 132 |
|
122 | 133 | if debug { |
123 | | - _, _ = fmt.Fprintf(stderr, "Checking skips for directory: %s\n", absDir) |
| 134 | + _, _ = fmt.Fprintf(stderr, "File: %s\n", filePath) |
| 135 | + _, _ = fmt.Fprintf(stderr, "Project root: %s\n", absProjectRoot) |
| 136 | + _, _ = fmt.Fprintf(stderr, "Checking skips for project root: %s\n", absProjectRoot) |
124 | 137 | if skipLint { |
125 | | - _, _ = fmt.Fprintf(stderr, "Skipping lint for directory: %s\n", absDir) |
| 138 | + _, _ = fmt.Fprintf(stderr, "Skipping lint for project: %s\n", absProjectRoot) |
126 | 139 | } |
127 | 140 | if skipTest { |
128 | | - _, _ = fmt.Fprintf(stderr, "Skipping test for directory: %s\n", absDir) |
| 141 | + _, _ = fmt.Fprintf(stderr, "Skipping test for project: %s\n", absProjectRoot) |
129 | 142 | } |
130 | 143 | } |
131 | 144 |
|
|
0 commit comments