Skip to content

Commit 5dcac3e

Browse files
committed
fix(cli): fix dev owners subdirectory path matching
Fixed 'No ownership data found' error when running dev owners from subdirectories like packages/. Root cause: File paths in topFiles are absolute (from database), but subdirectory mode was comparing them against relative paths. Solution: Normalize absolute paths by stripping repository prefix before comparison, matching the approach used in root directory mode.
1 parent 13cb5c2 commit 5dcac3e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/cli/src/commands/owners.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,10 @@ function formatSubdirectoryMode(
480480
): string {
481481
// Filter developers to only those with files in current directory
482482
const relevantDevs = developers.filter((dev) =>
483-
dev.topFiles.some((f) => f.path.startsWith(`${repositoryPath}/${currentDir}`))
483+
dev.topFiles.some((f) => {
484+
const relativePath = f.path.replace(`${repositoryPath}/`, '');
485+
return relativePath.startsWith(currentDir);
486+
})
484487
);
485488

486489
if (relevantDevs.length === 0) {
@@ -498,7 +501,10 @@ function formatSubdirectoryMode(
498501

499502
// Show top files in this directory
500503
const filesInDir = primary.topFiles
501-
.filter((f) => f.path.startsWith(`${repositoryPath}/${currentDir}`))
504+
.filter((f) => {
505+
const relativePath = f.path.replace(`${repositoryPath}/`, '');
506+
return relativePath.startsWith(currentDir);
507+
})
502508
.slice(0, 5);
503509

504510
if (filesInDir.length > 0) {

0 commit comments

Comments
 (0)