From 32a914bd3eafb8d806465818484515b744867835 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 24 Oct 2022 20:24:04 -0700 Subject: [PATCH] Cherry pick dyladan/component-owners#14 --- README.md | 4 ++++ src/utils.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 8fa13a0..b8bb181 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ components: - user3 - user4 + # User assignment can be configured based on a file extension + "*.md": + - user5 + # Optionally ignore some PR authors to reduce spam for assignees and reviewers ignored-authors: - dependabot diff --git a/src/utils.ts b/src/utils.ts index 2ad996e..c0778d0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -53,6 +53,11 @@ function match(name: string, ownedPath: string): boolean { // Remove leading and trailing path separator ownedPath = ownedPath.replace(/^\//, "").replace(/\/$/, ""); + if (ownedPath.startsWith("*.")) { + const extension = ownedPath.substring(1) + return name.endsWith(extension) + } + const ownedPathParts = ownedPath.split(path.sep); const filePathParts = name.split(path.sep).slice(0, ownedPathParts.length);