From 8ca7ffdd4a9c8726964776b1bc927bf1cef6262c Mon Sep 17 00:00:00 2001 From: "oppili.bsky.social" Date: Sun, 13 Apr 2025 09:13:28 +0000 Subject: [PATCH] appview: fix and refactor resubmit endpoint - ksClient returns strong types in its API - ResubmitPull is broken down into 3 flows similar to NewPull there is quite a bit of duplication going on here; but i imagine this is solved by introducing the xrpc layer down the line. --- appview/db/pulls.go | 16 +- .../templates/fragments/pullActions.html | 4 +- appview/pages/templates/repo/pulls/pull.html | 6 +- appview/pages/templates/repo/pulls/pulls.html | 4 +- appview/state/pull.go | 536 +++++++++++------- appview/state/signer.go | 34 +- flake.nix | 2 +- 7 files changed, 396 insertions(+), 206 deletions(-) diff --git a/appview/db/pulls.go b/appview/db/pulls.go index 037612d..6cca86c 100644 --- a/appview/db/pulls.go +++ b/appview/db/pulls.go @@ -122,7 +122,11 @@ func (p *Pull) LastRoundNumber() int { return len(p.Submissions) - 1 } -func (p *Pull) IsSameRepoBranch() bool { +func (p *Pull) IsPatchBased() bool { + return p.PullSource == nil +} + +func (p *Pull) IsBranchBased() bool { if p.PullSource != nil { if p.PullSource.RepoAt != nil { return p.PullSource.RepoAt == &p.RepoAt @@ -134,8 +138,14 @@ func (p *Pull) IsSameRepoBranch() bool { return false } -func (p *Pull) IsPatch() bool { - return p.PullSource == nil +func (p *Pull) IsForkBased() bool { + if p.PullSource != nil { + if p.PullSource.RepoAt != nil { + // make sure repos are different + return p.PullSource.RepoAt != &p.RepoAt + } + } + return false } func (s PullSubmission) AsNiceDiff(targetBranch string) types.NiceDiff { diff --git a/appview/pages/templates/fragments/pullActions.html b/appview/pages/templates/fragments/pullActions.html index 7b1d560..54bf14e 100644 --- a/appview/pages/templates/fragments/pullActions.html +++ b/appview/pages/templates/fragments/pullActions.html @@ -9,7 +9,7 @@ {{ $isConflicted := and .MergeCheck (or .MergeCheck.Error .MergeCheck.IsConflicted) }} {{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }} {{ $isLastRound := eq $roundNumber $lastIdx }} - {{ $isSameRepoBranch := .Pull.IsSameRepoBranch }} + {{ $isSameRepoBranch := .Pull.IsBranchBased }} {{ $isUpToDate := .ResubmitCheck.No }}
@@ -42,7 +42,7 @@ {{ $disabled = "disabled" }} {{ end }}