Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/pages,appview/pulls: refresh workflow files changed warning UI

Signed-off-by: dawn <dawn@tangled.org>

dawn (Jul 9, 2026, 1:18 PM +0300) 12afa074 b9165c8d

+252 -194
+7 -6
appview/pages/pages.go
··· 1442 1442 ActiveRound int 1443 1443 IsInterdiff bool 1444 1444 1445 - // WorkflowsChanged and ChangedWorkflowFiles describe whether the latest 1446 - // round's patch touches .tangled/workflows/, for warning maintainers 1447 - // before they manually trigger CI on a fork-based pull request. 1448 - WorkflowsChanged bool 1449 - ChangedWorkflowFiles []string 1450 - 1451 1445 Reactions map[syntax.ATURI]map[models.ReactionKind]models.ReactionDisplayData 1452 1446 UserReacted map[syntax.ATURI]map[models.ReactionKind]bool 1453 1447 ··· 1481 1475 ResubmitCheck ResubmitResult 1482 1476 BranchDeleteStatus *models.BranchDeleteStatus 1483 1477 Stack models.Stack 1478 + 1479 + // Workflow warning state for fork-based pulls without a pipeline on the 1480 + // latest commit. WorkflowsChanged and ChangedWorkflowFiles are computed 1481 + // from the latest round's patch. 1482 + WorkflowsChanged bool 1483 + ChangedWorkflowFiles []string 1484 + HasPipeline bool 1484 1485 1485 1486 // renders buttons in a pre-check state and attaches the hx-trigger="load" 1486 1487 // that fetches the real, checked fragment
+191 -84
appview/pages/templates/repo/pulls/fragments/pullActions.html
··· 23 23 {{ $isLastRound := eq $roundNumber $lastIdx }} 24 24 {{ $isSameRepoBranch := .Pull.IsBranchBased }} 25 25 {{ $isUpToDate := .ResubmitCheck.No }} 26 - <div id="actions-{{$roundNumber}}" hx-target="this" class="{{ if .LoggedInUser }}flex flex-wrap gap-2 relative p-2{{ else }}hidden{{ end }}" 26 + {{ $isForkBased := .Pull.IsForkBased }} 27 + {{ $showRunCI := and (not $loading) $isPushAllowed $isOpen $isLastRound $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }} 28 + 29 + <div id="action-card-{{$roundNumber}}" class="{{ if .LoggedInUser }}relative p-2 flex flex-col gap-2{{ else }}hidden{{ end }}" 27 30 {{ if $loading }} 28 31 hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/actions" 29 32 hx-trigger="load" 30 33 hx-swap="outerHTML" 34 + hx-target="this" 31 35 {{ end }} 32 36 > 33 - {{ if .LoggedInUser }} 34 - <button 35 - hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/comment" 36 - class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group"> 37 - {{ i "message-square-plus" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 38 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 39 - Comment 40 - </button> 37 + {{ if and (not $loading) $isLastRound }} 38 + {{ if and $isOpen $isForkBased (not .HasPipeline) (ne .RepoInfo.Spindle "") }} 39 + {{ template "workflowWarning" . }} 40 + {{ end }} 41 + {{ template "mergeCheck" . }} 42 + {{ template "resubmitStatus" . }} 41 43 {{ end }} 42 - {{ if and (not $loading) .BranchDeleteStatus }} 44 + <div id="actions-{{$roundNumber}}" hx-target="this" class="flex flex-wrap gap-2 relative" 45 + {{ if $loading }} 46 + hx-swap="outerHTML" 47 + {{ end }} 48 + > 49 + {{ if .LoggedInUser }} 43 50 <button 44 - hx-delete="/{{ resolve .BranchDeleteStatus.Repo.Did }}/{{ .BranchDeleteStatus.Repo.Slug }}/branches" 45 - hx-vals='{"branch": "{{ .BranchDeleteStatus.Branch }}" }' 51 + hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ $roundNumber }}/comment" 52 + class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group"> 53 + {{ i "message-square-plus" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 54 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 55 + Comment 56 + </button> 57 + {{ end }} 58 + {{ if and (not $loading) .BranchDeleteStatus }} 59 + <button 60 + hx-delete="/{{ resolve .BranchDeleteStatus.Repo.Did }}/{{ .BranchDeleteStatus.Repo.Slug }}/branches" 61 + hx-vals='{"branch": "{{ .BranchDeleteStatus.Branch }}" }' 62 + hx-swap="none" 63 + class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 64 + {{ i "git-branch" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 65 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 66 + Delete branch 67 + </button> 68 + {{ end }} 69 + {{ if $showRunCI }} 70 + {{ template "runCiModal" . }} 71 + {{ end }} 72 + {{ if and $isPushAllowed $isOpen $isLastRound }} 73 + <button 74 + hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge" 75 + hx-swap="none" 76 + hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?" 77 + class="btn-flat p-2 flex items-center gap-2 group" 78 + {{ if or $loading $isConflicted }}disabled{{ end }} 79 + > 80 + {{ if $loading }} 81 + {{ i "loader-circle" "w-4 h-4 animate-spin" }} 82 + {{ else }} 83 + {{ i "git-merge" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 84 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 85 + {{ end }} 86 + Merge{{if $stackCount}} {{$stackCount}}{{end}} 87 + </button> 88 + {{ end }} 89 + 90 + {{ if and $isPullAuthor $isOpen $isLastRound }} 91 + <button id="resubmitBtn" 92 + {{ if not .Pull.IsPatchBased }} 93 + hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 94 + hx-swap="none" 95 + {{ else }} 96 + hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 97 + {{ end }} 98 + 99 + hx-disabled-elt="#resubmitBtn" 100 + class="btn-flat p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" 101 + 102 + {{ if $loading }} 103 + title="Checking for updates…" 104 + disabled 105 + {{ else if $isUpToDate }} 106 + title="Update this branch to resubmit this pull request" 107 + disabled 108 + {{ else }} 109 + title="Resubmit this pull request" 110 + {{ end }} 111 + > 112 + {{ if $loading }} 113 + {{ i "loader-circle" "w-4 h-4 animate-spin" }} 114 + {{ else }} 115 + {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 116 + {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 117 + {{ end }} 118 + Resubmit 119 + </button> 120 + {{ end }} 121 + 122 + {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} 123 + <button 124 + hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close" 46 125 hx-swap="none" 47 - class="btn-flat p-2 flex items-center gap-2 no-underline hover:no-underline group text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 48 - {{ i "git-branch" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 126 + class="btn-flat p-2 flex items-center gap-2 group"> 127 + {{ i "ban" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 49 128 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 50 - Delete branch 129 + Close 51 130 </button> 52 - {{ end }} 53 - {{ if and $isPushAllowed $isOpen $isLastRound }} 131 + {{ end }} 132 + 133 + {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }} 54 134 <button 55 - hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge" 135 + hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen" 56 136 hx-swap="none" 57 - hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?" 58 - class="btn-flat p-2 flex items-center gap-2 group" 59 - {{ if or $loading $isConflicted }}disabled{{ end }} 60 - > 61 - {{ if $loading }} 62 - {{ i "loader-circle" "w-4 h-4 animate-spin" }} 63 - {{ else }} 64 - {{ i "git-merge" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 137 + class="btn-flat p-2 flex items-center gap-2 group"> 138 + {{ i "refresh-ccw-dot" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 65 139 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 66 - {{ end }} 67 - Merge{{if $stackCount}} {{$stackCount}}{{end}} 140 + Reopen 68 141 </button> 69 - {{ end }} 142 + {{ end }} 143 + </div> 144 + </div> 145 + {{ end }} 70 146 71 - {{ if and $isPullAuthor $isOpen $isLastRound }} 72 - <button id="resubmitBtn" 73 - {{ if not .Pull.IsPatchBased }} 74 - hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 75 - hx-swap="none" 76 - {{ else }} 77 - hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" 78 - {{ end }} 147 + {{ define "workflowWarning" }} 148 + {{ if .WorkflowsChanged }} 149 + <details class="group/ci"> 150 + <summary class="flex items-center gap-2 cursor-pointer list-none"> 151 + {{ i "triangle-alert" "w-4 h-4 text-amber-600 dark:text-amber-500" }} 152 + <span class="font-medium text-amber-600 dark:text-amber-500">Workflow files changed in this round</span> 153 + <div class="text-sm text-gray-500 dark:text-gray-400"> 154 + <span class="group-open/ci:hidden inline">Expand</span> 155 + <span class="hidden group-open/ci:inline">Collapse</span> 156 + </div> 157 + </summary> 158 + <ul class="space-y-1 mt-2 overflow-x-auto"> 159 + {{ range .ChangedWorkflowFiles }} 160 + <li class="flex items-center whitespace-nowrap"> 161 + {{ i "file-warning" "inline-flex w-4 h-4 mr-1.5 text-amber-600 dark:text-amber-500 flex-shrink-0" }} 162 + <span class="font-mono">{{ . }}</span> 163 + </li> 164 + {{ end }} 165 + </ul> 166 + </details> 167 + {{ else }} 168 + <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 169 + {{ i "triangle-alert" "w-4 h-4" }} 170 + <span class="font-medium">Workflow needs approval</span> 171 + </div> 172 + {{ end }} 173 + {{ end }} 79 174 80 - hx-disabled-elt="#resubmitBtn" 81 - class="btn-flat p-2 flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed group" 175 + {{ define "runCiModal" }} 176 + <button 177 + class="btn-flat p-2 flex items-center gap-2 flex-shrink-0 group" 178 + popovertarget="run-ci-{{ .Pull.PullId }}" 179 + popovertargetaction="toggle" 180 + > 181 + {{ i "circle-play" "w-4 h-4 inline" }} 182 + Run CI 183 + </button> 82 184 83 - {{ if $loading }} 84 - title="Checking for updates…" 85 - disabled 86 - {{ else if $isUpToDate }} 87 - title="Update this branch to resubmit this pull request" 88 - disabled 89 - {{ else }} 90 - title="Resubmit this pull request" 185 + <div 186 + id="run-ci-{{ .Pull.PullId }}" 187 + popover 188 + class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 dark:text-white backdrop:bg-gray-400/50 dark:backdrop:bg-gray-800/50 w-full md:w-96 p-4 rounded drop-shadow overflow-visible" 189 + > 190 + <form 191 + hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/trigger-ci?confirm=1" 192 + hx-swap="none" 193 + hx-indicator="#run-ci-spinner-{{ .Pull.PullId }}" 194 + class="flex flex-col gap-2" 195 + > 196 + <label class="text-lg font-medium p-0">Run CI</label> 197 + {{ if .WorkflowsChanged }} 198 + <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 199 + {{ i "triangle-alert" "size-4" }} 200 + <span class="font-medium">Workflow files changed in this round</span> 201 + </div> 202 + <ul class="space-y-1 overflow-x-auto pl-6"> 203 + {{ range .ChangedWorkflowFiles }} 204 + <li class="flex items-center whitespace-nowrap"> 205 + {{ i "file-warning" "size-4 mr-1.5 text-amber-600 dark:text-amber-500 flex-shrink-0" }} 206 + <span class="font-mono text-sm">{{ . }}</span> 207 + </li> 91 208 {{ end }} 92 - > 93 - {{ if $loading }} 94 - {{ i "loader-circle" "w-4 h-4 animate-spin" }} 95 - {{ else }} 96 - {{ i "rotate-ccw" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 97 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 98 - {{ end }} 99 - Resubmit 100 - </button> 101 - {{ end }} 102 - 103 - {{ if and (or $isPullAuthor $isPushAllowed) $isOpen $isLastRound }} 104 - <button 105 - hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/close" 106 - hx-swap="none" 107 - class="btn-flat p-2 flex items-center gap-2 group"> 108 - {{ i "ban" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 109 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 110 - Close 111 - </button> 112 - {{ end }} 113 - 114 - {{ if and (or $isPullAuthor $isPushAllowed) $isClosed $isLastRound }} 115 - <button 116 - hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/reopen" 117 - hx-swap="none" 118 - class="btn-flat p-2 flex items-center gap-2 group"> 119 - {{ i "refresh-ccw-dot" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 120 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 121 - Reopen 122 - </button> 123 - {{ end }} 209 + </ul> 210 + <p class="text-sm text-gray-500 dark:text-gray-400">Workflow files changed in this round. Are you sure you want to run CI?</p> 211 + {{ else }} 212 + <div class="flex items-center gap-2 text-amber-600 dark:text-amber-500"> 213 + {{ i "triangle-alert" "size-4" }} 214 + <span class="font-medium">Workflow needs approval</span> 215 + </div> 216 + <p class="text-sm text-gray-500 dark:text-gray-400">This fork-based pull request needs approval to run CI. Are you sure?</p> 217 + {{ end }} 218 + <div class="flex gap-2 pt-2"> 219 + <button 220 + type="button" 221 + popovertarget="run-ci-{{ .Pull.PullId }}" 222 + popovertargetaction="hide" 223 + class="btn w-1/2 flex items-center gap-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300" 224 + > 225 + {{ i "x" "size-4" }} Cancel 226 + </button> 227 + <button type="submit" class="btn w-1/2 flex items-center"> 228 + <span class="inline-flex gap-2 items-center">{{ i "shield-check" "size-4" }} Approve</span> 229 + <span id="run-ci-spinner-{{ .Pull.PullId }}" class="group"> 230 + {{ i "loader-circle" "ml-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 231 + </span> 232 + </button> 233 + </div> 234 + <div id="pull-error" class="text-red-500 dark:text-red-400"></div> 235 + </form> 124 236 </div> 125 - 126 - {{ if and (not $loading) $isLastRound }} 127 - <div id="mergecheck-banner" hx-swap-oob="innerHTML">{{ template "mergeCheck" . }}</div> 128 - <div id="resubmit-banner" hx-swap-oob="innerHTML">{{ template "resubmitStatus" . }}</div> 129 - {{ end }} 130 237 {{ end }} 131 238 132 239 {{ define "mergeCheck" }}
-49
appview/pages/templates/repo/pulls/fragments/triggerCi.html
··· 1 - {{ define "repo/pulls/fragments/runCiButton" }} 2 - <button 3 - class="btn-flat p-2 flex items-center gap-2 flex-shrink-0 group" 4 - hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/trigger-ci{{ if .Confirm }}?confirm=1{{ end }}" 5 - hx-swap="none" 6 - hx-disabled-elt="this" 7 - {{ if .Confirm }}hx-confirm="{{ .Confirm }}"{{ end }} 8 - > 9 - {{ i "circle-play" "w-4 h-4 inline group-[.htmx-request]:hidden" }} 10 - {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 11 - Run CI 12 - </button> 13 - {{ end }} 14 - 15 - {{ define "repo/pulls/fragments/triggerCi" }} 16 - {{ if .WorkflowsChanged }} 17 - <details class="group/ci"> 18 - <summary class="flex items-center justify-between gap-2 cursor-pointer list-none"> 19 - <div class="flex items-center gap-2 min-w-0 text-amber-600 dark:text-amber-500"> 20 - {{ i "triangle-alert" "w-4 h-4 flex-shrink-0" }} 21 - <span class="font-medium truncate">Workflow files changed in this round</span> 22 - <div class="text-sm text-gray-500 dark:text-gray-400"> 23 - <span class="group-open/ci:hidden inline">Expand</span> 24 - <span class="hidden group-open/ci:inline">Collapse</span> 25 - </div> 26 - </div> 27 - </summary> 28 - <ul class="space-y-1 mt-2 overflow-x-auto"> 29 - {{ range .ChangedWorkflowFiles }} 30 - <li class="flex items-center whitespace-nowrap"> 31 - {{ i "file-warning" "inline-flex w-4 h-4 mr-1.5 text-amber-600 dark:text-amber-500 flex-shrink-0" }} 32 - <span class="font-mono">{{ . }}</span> 33 - </li> 34 - {{ end }} 35 - </ul> 36 - <div class="mt-2"> 37 - {{ $confirm := printf "Workflow files changed in this round (%s). Review before running. Run anyway?" (join .ChangedWorkflowFiles ", ") }} 38 - {{ template "repo/pulls/fragments/runCiButton" (dict "RepoInfo" .RepoInfo "Pull" .Pull "Confirm" $confirm) }} 39 - </div> 40 - </details> 41 - {{ else }} 42 - <div class="flex items-center gap-2 text-gray-600 dark:text-gray-400"> 43 - {{ i "circle-play" "w-4 h-4 flex-shrink-0" }} 44 - <span class="font-medium">CI hasn't run on the latest commit</span> 45 - {{ template "repo/pulls/fragments/runCiButton" (dict "RepoInfo" .RepoInfo "Pull" .Pull "Confirm" "") }} 46 - </div> 47 - {{ end }} 48 - <div id="pull-error" class="text-red-500 dark:text-red-400"></div> 49 - {{ end }}
-13
appview/pages/templates/repo/pulls/pull.html
··· 342 342 {{ template "submissionInfo" $ }} 343 343 {{ template "submissionCommits" $ }} 344 344 {{ template "submissionPipeline" $ }} 345 - {{ if eq $lastIdx $round }} 346 - <div id="mergecheck-banner"> 347 - {{ if $root.Pull.State.IsOpen }} 348 - <div class="flex items-center gap-2 text-gray-500 dark:text-gray-400"> 349 - {{ i "loader-circle" "w-4 h-4 animate-spin" }} 350 - <span>Checking mergeability…</span> 351 - </div> 352 - {{ end }} 353 - </div> 354 - {{ end }} 355 345 </div> 356 346 </div> 357 347 {{ end }} ··· 549 539 {{ end }} 550 540 </div> 551 541 </details> 552 - {{ else if and $root.Pull.IsForkBased (eq $item.RoundNumber $root.Pull.LastRoundNumber) $root.RepoInfo.Roles.IsOwner }} 553 - {{ template "repo/pulls/fragments/triggerCi" $root }} 554 542 {{ end }} 555 543 {{ end }} 556 544 ··· 594 582 <div class="relative -ml-10"> 595 583 {{ if eq $lastIdx $item.RoundNumber }} 596 584 {{ block "mergeStatus" $root }} {{ end }} 597 - <div id="resubmit-banner"></div> 598 585 <div id="pull-action-error" class="error empty:hidden"></div> 599 586 {{ end }} 600 587 </div>
+54 -40
appview/pulls/single.go
··· 63 63 // only the last round's buttons and banners use merge/resubmit checks 64 64 isLastRound := roundNumber == pull.LastRoundNumber() 65 65 branchDeleteStatus := s.branchDeleteStatus(r, f, pull) 66 + 67 + var workflowsChanged bool 68 + var changedWorkflows []string 69 + hasPipeline := false 70 + if isLastRound && f.Spindle != "" { 71 + pipelines, err := s.fetchPipelines(r.Context(), f.Spindle, f.RepoDid, []string{pull.LatestSha()}) 72 + if err != nil { 73 + l.Error("failed to fetch latest pipeline", "err", err) 74 + } else if pipelines != nil { 75 + _, hasPipeline = pipelines[pull.LatestSha()] 76 + } 77 + 78 + if pull.IsForkBased() && !hasPipeline { 79 + changedWorkflows, err = changedWorkflowFiles(pull.LatestSubmission().CombinedPatch()) 80 + if err != nil { 81 + l.Error("failed to inspect latest round's patch for workflow changes", "err", err) 82 + } 83 + workflowsChanged = len(changedWorkflows) > 0 84 + } 85 + } 86 + 66 87 mergeCheckResponse := types.MergeCheckResponse{} 67 88 resubmitResult := pages.Unknown 68 89 if isLastRound { ··· 73 94 } 74 95 75 96 s.pages.PullActionsFragment(w, pages.PullActionsParams{ 76 - BaseParams: pages.BaseParamsFromContext(r.Context()), 77 - RepoInfo: s.repoResolver.GetRepoInfo(r, user), 78 - Pull: pull, 79 - RoundNumber: roundNumber, 80 - MergeCheck: mergeCheckResponse, 81 - ResubmitCheck: resubmitResult, 82 - BranchDeleteStatus: branchDeleteStatus, 83 - Stack: stack, 97 + BaseParams: pages.BaseParamsFromContext(r.Context()), 98 + RepoInfo: s.repoResolver.GetRepoInfo(r, user), 99 + Pull: pull, 100 + RoundNumber: roundNumber, 101 + MergeCheck: mergeCheckResponse, 102 + ResubmitCheck: resubmitResult, 103 + BranchDeleteStatus: branchDeleteStatus, 104 + Stack: stack, 105 + WorkflowsChanged: workflowsChanged, 106 + ChangedWorkflowFiles: changedWorkflows, 107 + HasPipeline: hasPipeline, 84 108 }) 85 109 return 86 110 } ··· 160 184 shas = append(shas, p.LatestSha()) 161 185 } 162 186 163 - // commitId -> latest pipeline 164 - pipelines := func(ctx context.Context) map[string]types.Pipeline { 165 - m := make(map[string]types.Pipeline) 166 - if f.Spindle == "" { 167 - return m 168 - } 169 - spindleUrl, err := hostutil.EnsureHttpScheme(f.Spindle) 170 - if err != nil { 171 - l.Error("invalid spindle host", "host", f.Spindle, "err", err) 172 - return m 173 - } 174 - xrpcc := &indigoxrpc.Client{Host: spindleUrl} 175 - out, err := tangled.CiQueryPipelines(ctx, xrpcc, shas, "", 0, f.RepoDid) 176 - if err != nil { 177 - l.Error("failed to fetch pipelines", "err", err) 178 - return m 179 - } 180 - 181 - return types.PipelinesByCommit(out.Pipelines) 182 - }(r.Context()) 183 - 184 - var workflowsChanged bool 185 - var changedWorkflows []string 186 - if _, hasPipeline := pipelines[pull.LatestSha()]; pull.IsForkBased() && !hasPipeline { 187 - changedWorkflows, err = changedWorkflowFiles(pull.LatestSubmission().CombinedPatch()) 188 - if err != nil { 189 - l.Error("failed to inspect latest round's patch for workflow changes", "err", err) 190 - } 191 - workflowsChanged = len(changedWorkflows) > 0 187 + pipelines, err := s.fetchPipelines(r.Context(), f.Spindle, f.RepoDid, shas) 188 + if err != nil { 189 + l.Error("failed to fetch pipelines", "err", err) 190 + } 191 + if pipelines == nil { 192 + pipelines = make(map[string]types.Pipeline) 192 193 } 193 194 194 195 entities := []syntax.ATURI{pull.AtUri()} ··· 278 279 ActiveRound: roundIdInt, 279 280 IsInterdiff: interdiff, 280 281 281 - WorkflowsChanged: workflowsChanged, 282 - ChangedWorkflowFiles: changedWorkflows, 283 - 284 282 Reactions: reactions, 285 283 UserReacted: userReactions, 286 284 ··· 303 301 diff := patchutil.AsNiceDiff(submission.CombinedPatch(), pull.TargetBranch) 304 302 s.diffCache.Add(key, diff) 305 303 return diff 304 + } 305 + 306 + func (s *Pulls) fetchPipelines(ctx context.Context, spindle string, repoDid string, shas []string) (map[string]types.Pipeline, error) { 307 + if spindle == "" { 308 + return nil, nil 309 + } 310 + spindleUrl, err := hostutil.EnsureHttpScheme(spindle) 311 + if err != nil { 312 + return nil, err 313 + } 314 + xrpcc := &indigoxrpc.Client{Host: spindleUrl} 315 + out, err := tangled.CiQueryPipelines(ctx, xrpcc, shas, "", 0, repoDid) 316 + if err != nil { 317 + return nil, err 318 + } 319 + return types.PipelinesByCommit(out.Pipelines), nil 306 320 } 307 321 308 322 func (s *Pulls) RepoSinglePull(w http.ResponseWriter, r *http.Request) {
-2
types/pipeline.go
··· 103 103 return t 104 104 } 105 105 106 - 107 - 108 106 type Trigger struct { 109 107 *tangled.CiPipeline_Trigger 110 108 }