Skip to content

[SDTEST-3516] fix codeowners parser#199

Merged
ypopovych merged 11 commits into
mainfrom
sdtest-3516-bugfix-codeowners-parser
Mar 9, 2026
Merged

[SDTEST-3516] fix codeowners parser#199
ypopovych merged 11 commits into
mainfrom
sdtest-3516-bugfix-codeowners-parser

Conversation

@ypopovych

Copy link
Copy Markdown
Contributor

What and why?

Implemented new CODEOWNERS parser for better path mathing support.

How?

By generating Regex statements for globs

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference

@ypopovych
ypopovych requested review from a team as code owners March 6, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR rewrites the CODEOWNERS file parser to use regex-based pattern matching instead of the previous simple string matching approach. The new implementation generates NSRegularExpression patterns from CODEOWNERS glob syntax, supporting features like ** directory matching, ? wildcard, character ranges [...], negated patterns !, escape sequences, GitLab-style sections with approval counts, and section default owners.

Changes:

  • Replaced the old CodeOwners parser with a new regex-based implementation using a SlidingWindow pattern compiler that converts CODEOWNERS glob patterns to NSRegularExpression
  • Changed the CodeOwners initializers from failable (init?) to throwing (throws(ParsingError)) with a new typed error enum
  • Added comprehensive tests ported from the Ruby datadog-ci-rb matcher spec, covering edge cases like escaped characters, Unicode paths, character ranges, and section exclusion semantics

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
Sources/DatadogSDKTesting/Utils/CodeOwners.swift Complete rewrite of CODEOWNERS parser: new SlidingWindow-based pattern compiler generating NSRegularExpression from globs, support for sections, negation, character ranges, and escape sequences
Tests/DatadogSDKTesting/Utils/CodeOwnersTests.swift Updated existing tests for new API, added extensive new test classes covering matcher spec, parser edge cases, character ranges, Unicode paths, and escape handling
Sources/DatadogSDKTesting/DDTestMonitor.swift Updated caller to handle throwing initializer with do-catch instead of optional return

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Tests/DatadogSDKTesting/Utils/CodeOwnersTests.swift Outdated
Comment thread Sources/DatadogSDKTesting/Utils/CodeOwners.swift Outdated
Comment thread Sources/DatadogSDKTesting/Utils/CodeOwners.swift Outdated
Comment thread Tests/DatadogSDKTesting/Utils/CodeOwnersTests.swift Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/DatadogSDKTesting/Utils/CodeOwners.swift
Comment thread Sources/DatadogSDKTesting/Utils/CodeOwners.swift Outdated

Copilot AI commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

@ypopovych I've opened a new pull request, #200, to work on those changes. Once the pull request is ready, I'll request review from you.

Remove unused `index` parameter from `_isSectionHeader`

Co-authored-by: ypopovych <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: ypopovych <[email protected]>
@ypopovych
ypopovych merged commit 424e294 into main Mar 9, 2026
1 check passed
@ypopovych
ypopovych deleted the sdtest-3516-bugfix-codeowners-parser branch March 9, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants