diff --git a/config/sync_settings.production.toml b/config/sync_settings.production.toml index 3f06f35..09da976 100644 --- a/config/sync_settings.production.toml +++ b/config/sync_settings.production.toml @@ -148,6 +148,7 @@ notion_tasks_team = "Team" notion_tasks_milestone_relation = "Milestones" notion_tasks_text_assignee = "Text Assignee (Desktop)" notion_tasks_labels = "Keywords (Desktop)" +notion_tasks_target_milestone = "Target Milestone" notion_tasks_whiteboard = "Whiteboard (Desktop)" notion_tasks_repository = "" notion_tasks_review_url = "Patch URL" diff --git a/mzla_notion/sync/base.py b/mzla_notion/sync/base.py index 2e6612e..709c433 100644 --- a/mzla_notion/sync/base.py +++ b/mzla_notion/sync/base.py @@ -158,7 +158,7 @@ def __init__( self._setup_prop(tasks_properties, "notion_tasks_text_assignee", "rich_text_space_set") self._setup_prop(tasks_properties, "notion_tasks_repository", "select", unknown="skip") self._setup_prop(tasks_properties, "notion_tasks_labels", "multi_select", unknown="skip") - + self._setup_prop(tasks_properties, "notion_tasks_target_milestone", "rich_text") self._setup_prop(tasks_properties, "notion_tasks_whiteboard", "rich_text") self._setup_date_prop(tasks_properties, "notion_tasks_dates") self._setup_date_prop(tasks_properties, "notion_tasks_openclose") @@ -402,9 +402,10 @@ async def _get_task_notion_data(self, tracker_issue, parent_milestone_pages=None reviewers = [user.notion_user for user in tracker_issue.reviewers if user.notion_user is not None] self._set_if_prop(notion_data, "notion_tasks_reviewers", reviewers) - # Labels and Whiteboard + # Labels and Whiteboard and Target Milestone self._set_if_prop(notion_data, "notion_tasks_labels", tracker_issue.labels or []) self._set_if_prop(notion_data, "notion_tasks_whiteboard", tracker_issue.whiteboard) + self._set_if_prop(notion_data, "notion_tasks_target_milestone", tracker_issue.target_milestone) # Repository repomap = self.propnames.get("notion_tasks_repository_map") or {} diff --git a/mzla_notion/tracker/bugzilla.py b/mzla_notion/tracker/bugzilla.py index 623e4e9..8961a49 100644 --- a/mzla_notion/tracker/bugzilla.py +++ b/mzla_notion/tracker/bugzilla.py @@ -314,7 +314,7 @@ def _set_if(data, prop, bzname): async def _get_bugzilla_bugs(self, bugids, sub_issues=False): issues = {} review_urls = {} - fields = "id,summary,status,resolution,product,cf_user_story,assigned_to,priority,cf_fx_points,depends_on,blocks,attachments,comments,see_also,creation_time,cf_last_resolved,keywords,whiteboard" + fields = "id,summary,status,resolution,product,cf_user_story,assigned_to,priority,cf_fx_points,depends_on,blocks,attachments,comments,see_also,creation_time,cf_last_resolved,keywords,whiteboard,target_milestone" response = await self.client.get("/bug", params={"id": ",".join(bugids), "include_fields": fields}) response_json = response.json() @@ -364,6 +364,7 @@ async def _get_bugzilla_bugs(self, bugids, sub_issues=False): state=status, labels=labels, whiteboard=bug["whiteboard"] or "", + target_milestone=bug["target_milestone"] if bug["target_milestone"] != "---" else None, description=bug["cf_user_story"] or getnestedattr(lambda: bug["comments"][0]["text"], ""), assignees={User(self.user_map, tracker_user=assignee)} if assignee else set(), priority=bug["priority"] if bug["priority"] != "--" else None, diff --git a/mzla_notion/tracker/common.py b/mzla_notion/tracker/common.py index fc5a388..be05a73 100644 --- a/mzla_notion/tracker/common.py +++ b/mzla_notion/tracker/common.py @@ -46,6 +46,7 @@ class Issue(IssueRef): sprint: Sprint = None sub_issues: list = field(default_factory=list) whiteboard: str = "" + target_milestone: str = "" requested_ref: IssueRef = None @@ -103,6 +104,7 @@ class IssueTracker: "notion_tasks_reviewers": "", # Default is disabled "notion_tasks_labels": "", # Default is disabled "notion_tasks_whiteboard": "", # Default is disabled + "notion_tasks_target_milestone": "", # Default is disabled "notion_tasks_repository": "", # Default is disabled "notion_tasks_openclose": "", # Default is disabled "notion_milestones_team": "", # Default is disabled diff --git a/test/fixtures/bugzilla/bug1849476.json b/test/fixtures/bugzilla/bug1849476.json index 5cfc745..6ad7e95 100644 --- a/test/fixtures/bugzilla/bug1849476.json +++ b/test/fixtures/bugzilla/bug1849476.json @@ -1,44 +1,45 @@ { - "assigned_to" : "user1@example.com", - "assigned_to_detail" : { - "email" : "user1@example.com", - "id" : 550104, - "name" : "user1@example.com", - "nick" : "TbSync", - "real_name" : "John Bieling (:TbSync)" - }, - "attachments" : [ - { - "attacher" : "user1@example.com", - "bug_id" : 1849476, - "content_type" : "text/x-phabricator-request", - "creation_time" : "2025-02-05T09:23:43Z", - "creator" : "user1@example.com", - "creator_detail" : {}, - "data" : "aHR0cHM6Ly9waGFicmljYXRvci5zZXJ2aWNlcy5tb3ppbGxhLmNvbS9EMjM2ODM2", - "description" : "Bug 1849476 - Make messages.move/copy() set mail.last_msg_movecopy_* preferences. r=#thunderbird-reviewers", - "file_name" : "phabricator-D236836-url.txt", - "flags" : [], - "id" : 9463983, - "is_obsolete" : 0, - "is_patch" : 0, - "is_private" : 0, - "last_change_time" : "2025-02-05T09:25:02Z", - "size" : 48, - "summary" : "Bug 1849476 - Make messages.move/copy() set mail.last_msg_movecopy_* preferences. r=#thunderbird-reviewers" - } - ], - "blocks" : [], - "cf_last_resolved" : "2025-02-06T10:18:39Z", - "cf_user_story" : "", - "creation_time" : "2023-08-19T18:40:32Z", - "depends_on" : [], - "id" : 1849476, - "priority" : "--", - "see_also" : [], - "status" : "RESOLVED", - "resolution": "FIXED", - "keywords": [], - "whiteboard": "", - "summary" : "messages.move/copy() doesn't set mail.last_msg_movecopy_target_uri" + "assigned_to": "user1@example.com", + "assigned_to_detail": { + "email": "user1@example.com", + "id": 550104, + "name": "user1@example.com", + "nick": "TbSync", + "real_name": "John Bieling (:TbSync)" + }, + "attachments": [ + { + "attacher": "user1@example.com", + "bug_id": 1849476, + "content_type": "text/x-phabricator-request", + "creation_time": "2025-02-05T09:23:43Z", + "creator": "user1@example.com", + "creator_detail": {}, + "data": "aHR0cHM6Ly9waGFicmljYXRvci5zZXJ2aWNlcy5tb3ppbGxhLmNvbS9EMjM2ODM2", + "description": "Bug 1849476 - Make messages.move/copy() set mail.last_msg_movecopy_* preferences. r=#thunderbird-reviewers", + "file_name": "phabricator-D236836-url.txt", + "flags": [], + "id": 9463983, + "is_obsolete": 0, + "is_patch": 0, + "is_private": 0, + "last_change_time": "2025-02-05T09:25:02Z", + "size": 48, + "summary": "Bug 1849476 - Make messages.move/copy() set mail.last_msg_movecopy_* preferences. r=#thunderbird-reviewers" + } + ], + "blocks": [], + "cf_last_resolved": "2025-02-06T10:18:39Z", + "cf_user_story": "", + "creation_time": "2023-08-19T18:40:32Z", + "depends_on": [], + "id": 1849476, + "priority": "--", + "see_also": [], + "status": "RESOLVED", + "resolution": "FIXED", + "keywords": [], + "whiteboard": "", + "target_milestone": "---", + "summary": "messages.move/copy() doesn't set mail.last_msg_movecopy_target_uri" } diff --git a/test/fixtures/bugzilla/bug1944850.json b/test/fixtures/bugzilla/bug1944850.json index 2243853..08331ce 100644 --- a/test/fixtures/bugzilla/bug1944850.json +++ b/test/fixtures/bugzilla/bug1944850.json @@ -22,12 +22,8 @@ "cf_last_resolved": null, "creation_time": "2025-01-30T13:59:24Z", "assigned_to": "nobody@mozilla.org", - "blocks": [ - 1944847 - ], - "depends_on": [ - 1944885 - ], + "blocks": [1944847], + "depends_on": [1944885], "id": 1944850, "see_also": [], "priority": "--", @@ -36,6 +32,7 @@ "attachments": [], "keywords": [], "whiteboard": "", + "target_milestone": "---", "assigned_to_detail": { "nick": "nobody", "id": 1, diff --git a/test/fixtures/bugzilla/bug1944885.json b/test/fixtures/bugzilla/bug1944885.json index 7049148..15e10d0 100644 --- a/test/fixtures/bugzilla/bug1944885.json +++ b/test/fixtures/bugzilla/bug1944885.json @@ -7,6 +7,7 @@ "summary": "Read Calendar Event - Acceptance Widget", "keywords": [], "whiteboard": "", + "target_milestone": "154 Branch", "attachments": [ { "file_name": "phabricator-D248065-url.txt", @@ -91,7 +92,5 @@ "nick": "user1", "email": "user1@example.com" }, - "blocks": [ - 1944850 - ] + "blocks": [1944850] } diff --git a/test/test_project_bugzilla.py b/test/test_project_bugzilla.py index 15b9904..0022330 100644 --- a/test/test_project_bugzilla.py +++ b/test/test_project_bugzilla.py @@ -143,6 +143,7 @@ async def test_bugzilla_get_issues_by_number(self): self.assertEqual(issue.description, "Rebuild the Read Event dialog based on designs in blabla") self.assertEqual(issue.assignees, set()) self.assertEqual(issue.priority, None) + self.assertEqual(issue.target_milestone, None) self.assertEqual(issue.estimate, "") self.assertEqual(issue.parents, [IssueRef(repo="bugzilla.dev", id="1944847")]) self.assertEqual(len(issue.sub_issues), 1) @@ -153,6 +154,7 @@ async def test_bugzilla_get_issues_by_number(self): self.assertEqual(issue.state, "IN REVIEW") self.assertEqual(issue.review_url, "https://phabricator.services.mozilla.com/D248065") self.assertEqual(issue.notion_url, "https://www.notion.so/mzthunderbird/b183c949289f4282864cd373cb8b2cb7") + self.assertEqual(issue.target_milestone, "154 Branch") self.assertEqual(issue.estimate, "8") async def test_bugzilla_get_issues_reviewers(self):