{{ define "repo/pulls/fragments/pullStepReview" }}
{{ if not .Comparison }}
{{ if eq .Source "patch" }} Paste a patch above to see a comparison. {{ else }} Pick a source and target above to see a comparison. {{ end }}
{{ else }} {{ $commits := .Comparison.FormatPatch }} {{ if $commits }}
{{ if .IsStacked }} {{ i "chevrons-down-up" "w-4 h-4" }} Stack {{ len $commits }} pull request{{ if ne (len $commits) 1 }}s{{ end }} {{ else }} {{ len $commits }} commit{{ if ne (len $commits) 1 }}s{{ end }} {{ end }} {{ if and .SourceBranch .TargetBranch }} {{ .TargetBranch }} {{ i "arrow-left-right" "w-4 h-4 flex-shrink-0" }} {{ .SourceBranch }} {{ end }}
{{ if .IsStacked }} {{ template "pullReviewStackedCommits" . }} {{ else }} {{ template "pullReviewFlatCommits" . }} {{ end }}
{{ else if ne .Source "patch" }}
{{ if and .SourceBranch .TargetBranch (eq .SourceBranch .TargetBranch) }} Source and target are the same branch, nothing to merge. {{ else }} No commits between target and source. Make sure your source branch has commits not on the target. {{ end }}
{{ end }} {{ if and .Diff (not .IsStacked) }} {{ template "pullComposeFlatDiff" (list .Diff .DiffOpts) }} {{ end }} {{ if and .IsStacked $commits }} {{ template "pullSubmitRow" . }} {{ template "pullStackApplyAllScript" }} {{ end }} {{ end }}
{{ end }} {{ define "pullStackApplyAllScript" }} {{ end }} {{ define "pullReviewFlatCommits" }} {{ $commits := .Comparison.FormatPatch }} {{ end }} {{ define "pullReviewStackedCommits" }} {{ $root := . }} {{ $commits := .Comparison.FormatPatch }} {{ $previewUrl := printf "/%s/pulls/new/preview" .RepoInfo.FullName }} {{ $hasSidePanel := and $root.LabelDefs $root.RepoInfo.Roles.IsPushAllowed }} {{ end }} {{ define "pullReviewCommitTimestamp" }} {{ $p := .Patch }} {{ if or (not $p.AuthorDate.IsZero) $p.SHA }} {{ if not $p.AuthorDate.IsZero }} {{ template "repo/fragments/shortTimeAgo" $p.AuthorDate }} {{ end }} {{ if $p.SHA }} {{ slice $p.SHA 0 8 }} {{ end }} {{ end }} {{ end }} {{ define "pullReviewCommitActions" }} {{ $p := .Patch }} {{ $repoInfo := .RepoInfo }} {{ if $p.SHA }} {{ i "folder-code" "w-4 h-4" }} {{ end }} {{ end }} {{ define "pullStackedDiffArea" }} {{ $diff := .Diff }} {{ $opts := .DiffOpts }} {{ $cid := .Cid }} {{ $togId := printf "stack-%s-filesToggle" $cid }} {{ $colId := printf "stack-%s-collapseToggle" $cid }} {{ $filesId := printf "stack-%s-files" $cid }} {{ $diffAreaId := printf "stack-%s-diff-area" $cid }} {{ $filePrefix := printf "stack-%s-file-" $cid }} {{ $stat := $diff.Stats }} {{ $count := len $diff.ChangedFiles }}
{{ template "repo/fragments/diffStatPill" $stat }}
{{ template "repo/fragments/diffOpts" $opts }}
{{ if eq $count 0 }}

No differences found.

{{ else if le $count 5 }} {{ range $idx, $file := $diff.ChangedFiles }} {{ template "stackedDiffFile" (dict "Idx" $idx "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} {{ end }} {{ else }} {{ range $idx, $file := slice $diff.ChangedFiles 0 5 }} {{ template "stackedDiffFile" (dict "Idx" $idx "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} {{ end }} {{ $remaining := sub $count 5 }}
{{ i "chevron-right" "w-4 h-4" }} Show {{ $remaining }} more file{{ if ne $remaining 1 }}s{{ end }}
{{ range $idx, $file := slice $diff.ChangedFiles 5 }} {{ template "stackedDiffFile" (dict "Idx" (add $idx 5) "File" $file "IsSplit" $opts.Split "Prefix" $filePrefix) }} {{ end }}
{{ end }}
{{ end }} {{ define "stackedDiffFile" }} {{ $idx := .Idx }} {{ $file := .File }} {{ $isSplit := .IsSplit }} {{ $prefix := .Prefix }} {{ $isGenerated := false }} {{ $isDeleted := false }} {{ with $file }} {{ $n := .Names }} {{ $isDeleted = and (eq $n.New "") (ne $n.Old "") }} {{ if $n.New }} {{ $isGenerated = isGenerated $n.New }} {{ else if $n.Old }} {{ $isGenerated = isGenerated $n.Old }} {{ end }}
{{ i "chevron-right" "w-4 h-4" }} {{ template "repo/fragments/diffStatPill" .Stats }}
{{ if and $n.New $n.Old (ne $n.New $n.Old)}} {{ $n.Old }} {{ i "arrow-right" "w-4 h-4" }} {{ $n.New }} {{ else if $n.New }} {{ $n.New }} {{ else }} {{ $n.Old }} {{ end }} {{ if $isDeleted }} {{ i "circle-question-mark" "size-4" }} {{ else if $isGenerated }} {{ i "circle-question-mark" "size-4" }} {{ end }}
{{ $reason := .CanRender }} {{ if $reason }}

{{ $reason }}

{{ else }} {{ if $isSplit }} {{- template "repo/fragments/splitDiff" .Split -}} {{ else }} {{- template "repo/fragments/unifiedDiff" . -}} {{ end }} {{- end -}}
{{ end }} {{ end }} {{ define "pullComposeFlatDiff" }} {{ $diff := index . 0 }} {{ $opts := index . 1 }} {{ $files := $diff.ChangedFiles }} {{ $isSplit := $opts.Split }} {{ $count := len $files }} {{ $stat := $diff.Stats }}
{{ template "repo/fragments/diffStatPill" $stat }}
{{ template "repo/fragments/diffOpts" $opts }}
{{ if eq $count 0 }}

No differences found.

{{ else if le $count 5 }} {{ range $idx, $file := $files }} {{ template "diffFile" (list $idx $file $isSplit true) }} {{ end }} {{ else }} {{ range $idx, $file := slice $files 0 5 }} {{ template "diffFile" (list $idx $file $isSplit true) }} {{ end }} {{ $remaining := sub $count 5 }}
{{ i "chevron-right" "w-4 h-4" }} Show {{ $remaining }} more file{{ if ne $remaining 1 }}s{{ end }}
{{ range $idx, $file := slice $files 5 }} {{ template "diffFile" (list (add $idx 5) $file $isSplit true) }} {{ end }}
{{ end }}
{{ end }}