Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion bugwarrior/services/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class LinearIssue(Issue):

UNIQUE_KEY = (URL,)

# Linear exposes issue priority as an integer:
# 0 = No priority, 1 = Urgent, 2 = High, 3 = Medium, 4 = Low.
PRIORITY_MAP = {1: "H", 2: "H", 3: "M", 4: "L"}

def to_taskwarrior(self):
description = self.record.get("description")
created = self.parse_date(self.record.get("createdAt"))
Expand All @@ -89,7 +93,7 @@ def get(v, k, default=None):
).lower()
or None
),
"priority": self.config.default_priority,
"priority": self.get_priority(),
"entry": created,
"annotations": get(self.extra, "annotations", []),
"tags": self.get_tags(),
Expand Down Expand Up @@ -178,6 +182,7 @@ def __init__(self, *args, **kwargs):
name
}
identifier
priority
team {
name
}
Expand Down
37 changes: 34 additions & 3 deletions tests/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"name": "Done"
},
"identifier": "DUS-5",
"priority": 4,
"team": {
"name": "Dustin's Doings"
}
Expand Down Expand Up @@ -65,6 +66,7 @@
"name": "Todo"
},
"identifier": "DUS-1",
"priority": 1,
"team": {
"name": "Dustin's Doings"
}
Expand Down Expand Up @@ -143,7 +145,7 @@ def test_to_taskwarrior(self):
closed_timestamp = datetime(2025, 7, 26, 17, 3, 4, 0, tzinfo=timezone.utc)
expected_output = {
"project": "prj",
"priority": "M",
"priority": "L",
"entry": created_timestamp,
"annotations": [],
"tags": [],
Expand All @@ -170,7 +172,7 @@ def test_to_taskwarrior(self):
updated_timestamp = datetime(2025, 7, 24, 17, 8, 33, 0, tzinfo=timezone.utc)
expected_output = {
"project": None,
"priority": "M",
"priority": "H",
"entry": created_timestamp,
"annotations": [],
"tags": ["Improvement", "Feature"],
Expand Down Expand Up @@ -212,12 +214,41 @@ def test_issues(self):
"linearteam": "Dustin's Doings",
"linearupdated": updated_timestamp,
"linearurl": "https://linear.app/dustins-doings/issue/DUS-5/do-stuff",
"priority": "M",
"priority": "L",
"project": 'prj',
"tags": [],
}
self.assertEqual(TaskConstructor(issue).get_taskwarrior_record(), expected)

def test_priority_mapping(self):
# Linear priority integers must map onto taskwarrior's H/M/L buckets,
# with "No priority" (0) and a missing field both falling back to the
# service-wide default.
cases = [
(0, "M"), # No priority -> default_priority (M)
(1, "H"), # Urgent
(2, "H"), # High
(3, "M"), # Medium
(4, "L"), # Low
]
for linear_priority, expected in cases:
with self.subTest(linear_priority=linear_priority):
record = {
**RESPONSE["data"]["issues"]["nodes"][0],
"priority": linear_priority,
}
issue = self.service.get_issue_for_record(record, {})
self.assertEqual(issue.to_taskwarrior()["priority"], expected)

# A record without a priority key at all should also fall back.
record = {
k: v
for k, v in RESPONSE["data"]["issues"]["nodes"][0].items()
if k != "priority"
}
issue = self.service.get_issue_for_record(record, {})
self.assertEqual(issue.to_taskwarrior()["priority"], "M")

@responses.activate
def test_issues_paginates(self):
"""Drains every page when Linear signals ``hasNextPage``."""
Expand Down
Loading