Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import jira

from clusterfuzz._internal.config import db_config
from clusterfuzz._internal.metrics import logs


class IssueTrackerManager:
Expand Down Expand Up @@ -79,12 +80,25 @@ def _add_watchers(self, issue):
"""Add watchers to the ticket. Jira has a separate endpoint to
add watchers."""

# return if issue was not created yet
if issue.id == -1:
return

# Get watchers from LabelStore.
watchers = list(issue.ccs)

# Get existing watchers to avoid duplicate calls
existing_watchers = set(self.get_watchers(issue))

# Only add watchers that don't already exist
new_watchers = [w for w in watchers if w not in existing_watchers]

# Jira weirdness, update watchers this way.
for watcher in watchers:
self.client.add_watcher(issue.jira_issue, watcher)
for watcher in new_watchers:
try:
self.client.add_watcher(issue.jira_issue, watcher)
except Exception as e:
logs.error(f'Error adding watcher {watcher} to issue {issue.id}: {e}')

def _get_issue_fields(self, issue):
"""Get issue fields to populate the ticket"""
Expand Down
Loading