Skip to content

Commit

Permalink
Cherry-pick 274181@main (17c1a8d). rdar://122335573
Browse files Browse the repository at this point in the history
    [webkitbugspy] Redaction message should include related issue
    https://bugs.webkit.org/show_bug.cgi?id=268776
    rdar://problem/122335573

    Reviewed by Jonathan Bedard.

    Includes the related link in logging whenever an issue is redacted because of a related issue.

    * Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py:
    (Issue.redacted):
    * Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/bugzilla_unittest.py:
    * Tools/Scripts/libraries/webkitbugspy/webkitbugspy/tests/radar_unittest.py:

    Canonical link: https://commits.webkit.org/274181@main

Canonical link: https://commits.webkit.org/272448.571@safari-7618-branch
  • Loading branch information
briannafan authored and JonWBedard committed Feb 19, 2024
1 parent bc651bd commit a6f3190
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions Tools/Scripts/libraries/webkitbugspy/webkitbugspy/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,24 @@ def redacted(self):
reason="is a {}".format(self.tracker.NAME) if key.pattern == '.*' else "matches '{}'".format(key.pattern),
)

match_strings = [match_string]
match_strings = {self.link: match_string}
if self.original:
match_strings.append(self.original._redaction_match)
match_strings[self.original.link] = self.original._redaction_match
for dupe in self.duplicates or []:
match_strings.append(dupe._redaction_match)
match_strings[dupe.link] = dupe._redaction_match

for m_string in match_strings:
for m_link, m_string in match_strings.items():
for key, value in self.tracker._redact.items():
if key.search(m_string):
if key.pattern == '.*':
reason = "is a {}".format(self.tracker.NAME)
elif m_link != self.link:
reason = "is related to {} which matches '{}'".format(m_link, key.pattern)
else:
reason = "matches '{}'".format(key.pattern)
return self.tracker.Redaction(
redacted=value,
reason="is a {}".format(self.tracker.NAME) if key.pattern == '.*' else "matches '{}'".format(key.pattern),
reason=reason,
)
return self.tracker.Redaction(redacted=False)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def test_redacted_duplicate(self):
self.assertEqual(tracker.issue(1).redacted, bugzilla.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, False)
tracker.issue(1).close(original=tracker.issue(2))
self.assertEqual(tracker.issue(2).redacted, bugzilla.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, bugzilla.Tracker.Redaction(True, "is related to https://bugs.example.com/show_bug.cgi?id=1 which matches 'component:Text'"))

def test_redacted_original(self):
with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, environment=wkmocks.Environment(
Expand All @@ -466,7 +466,7 @@ def test_redacted_original(self):
self.assertEqual(tracker.issue(1).redacted, bugzilla.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, False)
tracker.issue(2).close(original=tracker.issue(1))
self.assertEqual(tracker.issue(2).redacted, bugzilla.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, bugzilla.Tracker.Redaction(True, "is related to https://bugs.example.com/show_bug.cgi?id=1 which matches 'component:Text'"))

def test_redaction_exception(self):
with mocks.Bugzilla(self.URL.split('://')[1], issues=mocks.ISSUES, projects=mocks.PROJECTS):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ def test_redacted_duplicate(self):
self.assertEqual(tracker.issue(1).redacted, radar.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, False)
tracker.issue(1).close(original=tracker.issue(2))
self.assertEqual(tracker.issue(2).redacted, radar.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, radar.Tracker.Redaction(True, "is related to rdar://1 which matches 'component:Text'"))

def test_redacted_original(self):
with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES, projects=mocks.PROJECTS):
tracker = radar.Tracker(project='WebKit', redact={'component:Text': True})
self.assertEqual(tracker.issue(1).redacted, radar.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, False)
tracker.issue(2).close(original=tracker.issue(1))
self.assertEqual(tracker.issue(2).redacted, radar.Tracker.Redaction(True, "matches 'component:Text'"))
self.assertEqual(tracker.issue(2).redacted, radar.Tracker.Redaction(True, "is related to rdar://1 which matches 'component:Text'"))

def test_redaction_exception(self):
with wkmocks.Environment(RADAR_USERNAME='tcontributor'), mocks.Radar(issues=mocks.ISSUES, projects=mocks.PROJECTS):
Expand Down

0 comments on commit a6f3190

Please sign in to comment.