|
1 | 1 | import logging |
2 | 2 | import re |
3 | 3 | import urllib.parse |
4 | | -from typing import Optional |
5 | 4 |
|
6 | 5 | from compressor.contrib.jinja2ext import CompressorExtension |
7 | 6 | from django.conf import settings |
|
13 | 12 | from markupsafe import Markup |
14 | 13 |
|
15 | 14 | from lando.main.models import JobStatus, LandingJob, Repo, UpliftJob |
| 15 | +from lando.main.models.revision import Revision |
16 | 16 | from lando.main.scm import SCM_TYPE_GIT |
17 | 17 | from lando.treestatus.models import ( |
18 | 18 | ReasonCategory, |
@@ -314,7 +314,11 @@ def bug_url(text: str) -> str: |
314 | 314 | ) |
315 | 315 |
|
316 | 316 |
|
317 | | -def revision_url(revision_id: int | str, diff_id: Optional[str] = None) -> str: |
| 317 | +def pull_request_link(repo: Repo, revision: Revision) -> str: |
| 318 | + return f"{repo.url.removesuffix('.git')}/pull/{ revision.pull_number }" |
| 319 | + |
| 320 | + |
| 321 | +def revision_url(revision_id: int | str, diff_id: str | None = None) -> str: |
318 | 322 | if isinstance(revision_id, int): |
319 | 323 | path = f"D{revision_id}" |
320 | 324 | elif isinstance(revision_id, str) and not revision_id.startswith("D"): |
@@ -435,6 +439,7 @@ def environment(**options): # noqa: ANN201 |
435 | 439 | "config": settings, |
436 | 440 | "get_messages": messages.get_messages, |
437 | 441 | "graph_height": graph_height, |
| 442 | + "pull_request_link": pull_request_link, |
438 | 443 | "treeherder_link": treeherder_link, |
439 | 444 | "new_settings_form": UserSettingsForm, |
440 | 445 | "static_url": settings.STATIC_URL, |
|
0 commit comments