Skip to content

Commit

Permalink
Filter in-app frames to decide for CODEOWNERS
Browse files Browse the repository at this point in the history
  • Loading branch information
alxckn committed Mar 28, 2024
1 parent 80582ab commit fb4f2ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/sentry/ownership/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ def dump(self) -> Mapping[str, str]:
def load(cls, data: Mapping[str, str]) -> Matcher:
return cls(data["type"], data["pattern"])

@staticmethod
def munge_if_needed(data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]], Sequence[str]]:
def munge_if_needed(self, data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]], Sequence[str]]:
keys = ["filename", "abs_path"]
platform = data.get("platform")
sdk_name = get_sdk_name(data)
frames = find_stack_frames(data)
frames = self.find_in_app_stack_frames(data)
if platform:
munged = munged_filename_and_frames(platform, frames, "munged_filename", sdk_name)
if munged:
Expand All @@ -130,13 +129,17 @@ def munge_if_needed(data: PathSearchable) -> tuple[Sequence[Mapping[str, Any]],

return frames, keys

@staticmethod
def find_in_app_stack_frames(data: PathSearchable) -> Sequence[Mapping[str, Any]]:
return [frame for frame in find_stack_frames if frame.get("in_app")]

def test(self, data: PathSearchable) -> bool:
if self.type == URL:
return self.test_url(data)
elif self.type == PATH:
return self.test_frames(*self.munge_if_needed(data))
elif self.type == MODULE:
return self.test_frames(find_stack_frames(data), ["module"])
return self.test_frames(self.find_in_app_stack_frames(data), ["module"])
elif self.type.startswith("tags."):
return self.test_tag(data)
elif self.type == CODEOWNERS:
Expand Down

0 comments on commit fb4f2ae

Please sign in to comment.