|
1 | | -import { EOL } from 'os'; |
2 | | -import { join, relative, resolve, sep } from 'path'; |
| 1 | +import { relative, resolve, sep } from 'path'; |
3 | 2 | import * as cp from 'child_process'; |
4 | 3 | import { readFile } from 'fs/promises'; |
5 | 4 |
|
6 | | -import * as minimatch from 'minimatch'; // Only needed for githubValiator |
7 | 5 | import * as yaml from 'js-yaml'; |
8 | 6 | import * as vscode from 'vscode'; |
9 | 7 |
|
@@ -151,44 +149,6 @@ const mockValidator: Validator = (filepath) => { |
151 | 149 | ); |
152 | 150 | }; |
153 | 151 |
|
154 | | -/** |
155 | | - * Checks for file ownership by looking at the existing `.github/CODEOWNERS` file |
156 | | - * @param filepath path of the file to check |
157 | | - * @returns an {@link Owner Owner} object or `undefined` if no owner can be determined |
158 | | - */ |
159 | | -const githubValidator: Validator = async (filepath) => { |
160 | | - const config = vscode.Uri.parse( |
161 | | - join( |
162 | | - vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || '', |
163 | | - '.github', |
164 | | - 'CODEOWNERS', |
165 | | - ), |
166 | | - ); |
167 | | - |
168 | | - const rel = `${sep}${relative( |
169 | | - vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || '', |
170 | | - filepath, |
171 | | - )}`; |
172 | | - |
173 | | - const doc = await vscode.workspace.openTextDocument(config); |
174 | | - |
175 | | - const codeowners = doc.getText().split(EOL); |
176 | | - |
177 | | - for (const line of codeowners) { |
178 | | - const [pattern, teamName] = line.split(' '); |
179 | | - |
180 | | - if (minimatch(rel, pattern)) { |
181 | | - return { |
182 | | - filepath, |
183 | | - teamName, |
184 | | - teamConfig: config.fsPath, |
185 | | - }; |
186 | | - } |
187 | | - } |
188 | | - |
189 | | - return undefined; |
190 | | -}; |
191 | | - |
192 | 152 | const codeownershipValidator: Validator = async (filepath) => { |
193 | 153 | // bin/codeownership currenlty wants relative paths |
194 | 154 | const relativePath = relative(process.cwd(), filepath); |
|
0 commit comments