Skip to content

Commit

Permalink
pw_module: Fix OWNERS file parsing
Browse files Browse the repository at this point in the history
Comments were not being ignored.

Change-Id: I87fdafb5c5b6c83d473332536ef81072f6fc2576
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/226177
Commit-Queue: Wyatt Hepler <[email protected]>
Lint: Lint 🤖 <[email protected]>
Pigweed-Auto-Submit: Wyatt Hepler <[email protected]>
Reviewed-by: Keir Mierle <[email protected]>
  • Loading branch information
255 authored and CQ Bot Account committed Aug 12, 2024
1 parent c75f089 commit d1e7bba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pw_module/py/pw_module/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,16 @@ def _is_upstream() -> bool:
return _PW_ROOT == _project_root()


_COMMENTS = re.compile(r'\w*#.*$')


def _read_root_owners(project_root: Path) -> Iterable[str]:
for line in (project_root / 'OWNERS').read_text().splitlines():
line = _COMMENTS.sub('', line).strip()
if line:
yield line


def _create_module(
module: str,
languages: Iterable[str],
Expand Down Expand Up @@ -1117,7 +1127,7 @@ def _create_module(
'Owners should be email addresses, but found `%s`', owner
)
sys.exit(1)
root_owners = (project_root / 'OWNERS').read_text().split('\n')
root_owners = list(_read_root_owners(project_root))
if not any(owner in root_owners for owner in owners):
root_owners_str = '\n'.join(root_owners)
_LOG.error(
Expand Down

0 comments on commit d1e7bba

Please sign in to comment.