Skip to content

Commit

Permalink
Add github commit and compare URL to job detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jongmassey committed Feb 21, 2024
1 parent a5cbc7a commit 036e34f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions jobserver/views/jobs.py
Expand Up @@ -102,6 +102,15 @@ def get(self, request, *args, **kwargs):
honeycomb.previous_actions_link(job)
)

previous_job_request = JobRequest.objects.previous(job.job_request)
compare_url = (
job.job_request.workspace.repo.get_compare_url(
previous_job_request.sha, job.job_request.sha
)
if previous_job_request
else None
)

context = {
"cancellation_requested": job.action in job.job_request.cancelled_actions,
"job": job,
Expand All @@ -111,6 +120,7 @@ def get(self, request, *args, **kwargs):
"user_can_cancel_jobs": can_cancel_jobs,
"view": self,
"honeycomb_links": honeycomb_links,
"compare_url": compare_url,
}

return TemplateResponse(request, "job/detail.html", context=context)
Expand Down
10 changes: 10 additions & 0 deletions templates/job/detail.html
Expand Up @@ -185,6 +185,16 @@ <h1 class="min-w-0 text-3xl break-words md:text-4xl font-bold text-slate-900">
-
{% endif %}
{% /description_item %}

{% #description_item title="Git commit hash" stacked=True %}
{% link href=job.job_request.get_repo_url text=job.job_request.sha|slice:7|default:"-" %}
{% /description_item %}

{% if compare_url %}
{% #description_item title="Compare code" stacked=True %}
{% link href=compare_url text="View on GitHub" %}
{% /description_item %}
{% endif %}
</dl>
{% /card %}

Expand Down

0 comments on commit 036e34f

Please sign in to comment.