Skip to content

Commit

Permalink
Ref #548, #407: filter see_also for configured project
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Jun 2, 2023
1 parent 3ca6b12 commit 9bada17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions jbi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def issue_type(self) -> str:
type_map: dict = {"enhancement": "Task", "task": "Task", "defect": "Bug"}
return type_map.get(self.type, "Task")

def extract_from_see_also(self):
def extract_from_see_also(self, project_key):
"""Extract Jira Issue Key from see_also if jira url present"""
if not self.see_also or len(self.see_also) == 0:
return None
Expand All @@ -262,8 +262,10 @@ def extract_from_see_also(self):
continue

if any(part in JIRA_HOSTNAMES for part in host_parts):
# URL ending with /
parsed_jira_key = parsed_url.path.rstrip("/").split("/")[-1]
if parsed_jira_key: # URL ending with /
# eg. filter for specified project SNT-1234
if parsed_jira_key and project_key in parsed_jira_key:
return parsed_jira_key

return None
Expand Down
4 changes: 3 additions & 1 deletion jbi/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def execute_action(
f"private bugs are not valid for action {action.whiteboard_tag!r}"
)

linked_issue_key: Optional[str] = bug.extract_from_see_also()
linked_issue_key: Optional[str] = bug.extract_from_see_also(
project_key=action.jira_project_key
)

action_context = ActionContext(
rid=request.rid,
Expand Down

0 comments on commit 9bada17

Please sign in to comment.