From 8adb464c299499a46d9a86b9d1dcfcad5f4e07af Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sun, 28 Jun 2026 11:11:54 -0400 Subject: [PATCH 1/2] Document that query paths must be repo-relative (#40) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index a37cbd1..5f9f837 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,20 @@ owners = CodeOwners(example_file) assert owners.of("test.js") == [('USERNAME', '@ghost')] ``` +### Path format + +Paths passed to `of()` (and `matching_line()` / `section_name()`) must be +repo-relative with no leading slash, matching the behavior of the upstream +[Go](https://github.com/hmarr/codeowners/) and +[Rust](https://github.com/hmarr/codeowners-rs) libraries as well as +`git check-ignore`. A leading slash will not match: + +```python +owners = CodeOwners("/build/logs/log.txt @ghost") +assert owners.of("build/logs/log.txt") == [('USERNAME', '@ghost')] # ✅ +assert owners.of("/build/logs/log.txt") == [] # ✗ leading slash +``` + ## Dev ```shell From c798a3cbb630eb19175fc5ca6b5000c73e6f798f Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sun, 28 Jun 2026 11:15:39 -0400 Subject: [PATCH 2/2] cleanup --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5c9067a..1efa926 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,8 @@ assert owners.of("test.js") == [('USERNAME', '@ghost')] ### Path format -Paths passed to `of()` (and `matching_line()` / `section_name()`) must be -repo-relative with no leading slash, matching the behavior of the upstream -[Go](https://github.com/hmarr/codeowners/) and -[Rust](https://github.com/hmarr/codeowners-rs) libraries as well as -`git check-ignore`. A leading slash will not match: +Paths must be repo-relative with no leading slash, matching `git check-ignore`. A leading +slash will not match: ```python owners = CodeOwners("/build/logs/log.txt @ghost")