Skip to content

Commit

Permalink
add: ignore gitlab's code owner sections (#23)
Browse files Browse the repository at this point in the history
Doesn't add support, but ignores gitlab's sections

related: #20
  • Loading branch information
sbdchd authored Mar 16, 2021
1 parent 2817311 commit 9278ede
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion codeowners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ class CodeOwners:
def __init__(self, text: str) -> None:
paths: List[Tuple[Pattern[str], List[OwnerTuple]]] = []
for line in text.splitlines():
if line == "" or line.startswith("#"):
line = line.strip()
if (
line == ""
or line.startswith("#")
or (line.startswith("[") and line.endswith("]"))
or (line.startswith("^[") and line.endswith("]"))
):
continue
elements = iter(line.split())
path = next(elements, None)
Expand Down
11 changes: 11 additions & 0 deletions codeowners/test_codeowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@
# `docs/build-app/troubleshooting.md`.
docs/* docs@example.com
# Let's test GitLab's premium feature of sections
# see https://docs.gitlab.com/ee/user/project/code_owners.html#code-owners-sections
[First team]
[Another team trailing whitespace]
# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
apps/ @octocat
# Now, optional approval rule for GitLab's sections
^[Second team]
^[Second team trailing whitespace]
# In this example, @doctocat owns any file in the `/docs`
# directory in the root of your repository.
/docs/ @doctocat
Expand Down

0 comments on commit 9278ede

Please sign in to comment.