diff --git a/lib/workers/pr/code-owners.ts b/lib/workers/pr/code-owners.ts index c6efc89d9a1a125646966c8494cdad712eb787bb..4d0f28991ae14c01afc62ede0cef20dc4dd81dd0 100644 --- a/lib/workers/pr/code-owners.ts +++ b/lib/workers/pr/code-owners.ts @@ -5,6 +5,7 @@ import { readLocalFile } from '../../util/fs'; import { getBranchFiles } from '../../util/git'; export async function codeOwnersForPr(pr: Pr): Promise<string[]> { + logger.debug('Searching for CODEOWNERS file'); try { const codeOwnersFile = (await readLocalFile('CODEOWNERS', 'utf8')) || @@ -13,9 +14,12 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> { (await readLocalFile('docs/CODEOWNERS', 'utf8')); if (!codeOwnersFile) { + logger.debug('No CODEOWNERS file found'); return []; } + logger.debug(`Found CODEOWNERS file: ${codeOwnersFile}`); + const prFiles = await getBranchFiles(pr.sourceBranch); const rules = codeOwnersFile .split('\n') @@ -35,11 +39,17 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> { const matchingRule = rules.find((rule) => prFiles?.every(rule.match)); if (!matchingRule) { + logger.debug('No matching CODEOWNERS rule found'); return []; } + logger.debug( + `CODEOWNERS matched the following usernames: ${JSON.stringify( + matchingRule.usernames + )}` + ); return matchingRule.usernames; } catch (err) { - logger.warn({ err, pr }, 'Failed to determine code owners for PR.'); + logger.warn({ err, pr }, 'Failed to determine CODEOWNERS for PR.'); return []; } }