forked from tangled.org/core
this repo has no description

appview: pulls: fix commit links in format-patch submissions

the conditionals here were a bit confusing, branch-based PRs just
skipped commit links altogether.

Changed files
+11 -10
appview
pages
templates
repo
pulls
+11 -10
appview/pages/templates/repo/pulls/pull.html
···
<div class="flex items-center gap-2">
{{ i "git-commit-horizontal" "w-4 h-4" }}
<div class="text-sm text-gray-500 dark:text-gray-400">
-
{{ if not $.Pull.IsPatchBased }}
-
{{ $fullRepo := $.RepoInfo.FullName }}
-
{{ if $.Pull.IsForkBased }}
-
{{ if $.Pull.PullSource.Repo }}
-
{{ $fullRepo = printf "%s/%s" $owner $.Pull.PullSource.Repo.Name }}
-
<a href="/{{ $fullRepo }}/commit/{{ .SHA }}" class="font-mono text-gray-500 dark:text-gray-400">{{ slice .SHA 0 8 }}</a>
-
{{ else }}
-
<span class="font-mono">{{ slice .SHA 0 8 }}</span>
-
{{ end }}
-
{{ end }}
+
<!-- attempt to resolve $fullRepo: this is possible only on non-deleted forks and branches -->
+
{{ $fullRepo := "" }}
+
{{ if and $.Pull.IsForkBased $.Pull.PullSource.Repo }}
+
{{ $fullRepo = printf "%s/%s" $owner $.Pull.PullSource.Repo.Name }}
+
{{ else if $.Pull.IsBranchBased }}
+
{{ $fullRepo = $.RepoInfo.FullName }}
+
{{ end }}
+
+
<!-- if $fullRepo was resolved, link to it, otherwise just span without a link -->
+
{{ if $fullRepo }}
+
<a href="/{{ $fullRepo }}/commit/{{ .SHA }}" class="font-mono text-gray-500 dark:text-gray-400">{{ slice .SHA 0 8 }}</a>
{{ else }}
<span class="font-mono">{{ slice .SHA 0 8 }}</span>
{{ end }}