ATProto Browser

ATProto Browser

Experimental browser for the Atmosphere

Record data

{
  "uri": "at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3lnphlhyhza22",
  "cid": "bafyreiauzy4ow4y3g3ivvhast353rtmsepyibuortihe6nwhmp2xek2ica",
  "value": {
    "$type": "sh.tangled.repo.pull",
    "patch": "From 72e11e404f5cd7eee33d81a88fa08055552b0d36 Mon Sep 17 00:00:00 2001\nFrom: Akshay <nerdy@peppe.rs>\nDate: Fri, 25 Apr 2025 13:01:43 +0100\nSubject: [PATCH] appview: db: avoid setting PullAt\n\n---\n appview/db/pulls.go   | 25 +++++++++++--------------\n appview/state/pull.go |  7 +++----\n 2 files changed, 14 insertions(+), 18 deletions(-)\n\ndiff --git a/appview/db/pulls.go b/appview/db/pulls.go\nindex f2774b7..69efee4 100644\n--- a/appview/db/pulls.go\n+++ b/appview/db/pulls.go\n@@ -10,6 +10,7 @@ import (\n \n \t\"github.com/bluekeyes/go-gitdiff/gitdiff\"\n \t\"github.com/bluesky-social/indigo/atproto/syntax\"\n+\ttangled \"tangled.sh/tangled.sh/core/api/tangled\"\n \t\"tangled.sh/tangled.sh/core/patchutil\"\n \t\"tangled.sh/tangled.sh/core/types\"\n )\n@@ -54,7 +55,6 @@ type Pull struct {\n \tRepoAt   syntax.ATURI\n \tOwnerDid string\n \tRkey     string\n-\tPullAt   syntax.ATURI\n \n \t// content\n \tTitle        string\n@@ -120,6 +120,10 @@ func (p *Pull) LatestPatch() string {\n \treturn latestSubmission.Patch\n }\n \n+func (p *Pull) PullAt() syntax.ATURI {\n+\treturn syntax.ATURI(fmt.Sprintf(\"at://%s/%s/%s\", p.OwnerDid, tangled.RepoPullNSID, p.Rkey))\n+}\n+\n func (p *Pull) LastRoundNumber() int {\n \treturn len(p.Submissions) - 1\n }\n@@ -298,15 +302,12 @@ func NewPull(tx *sql.Tx, pull *Pull) error {\n \treturn nil\n }\n \n-func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {\n-\t_, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)\n-\treturn err\n-}\n-\n-func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {\n-\tvar pullAt string\n-\terr := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)\n-\treturn pullAt, err\n+func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error) {\n+\tpull, err := GetPull(e, repoAt, pullId)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\treturn pull.PullAt(), err\n }\n \n func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) {\n@@ -326,7 +327,6 @@ func GetPulls(e Execer, repoAt syntax.ATURI, state PullState) ([]*Pull, error) {\n \t\t\ttitle,\n \t\t\tstate,\n \t\t\ttarget_branch,\n-\t\t\tpull_at,\n \t\t\tbody,\n \t\t\trkey,\n \t\t\tsource_branch,\n@@ -351,7 +351,6 @@ func GetPulls(e Execer, repoAt syntax.ATURI, state PullState) ([]*Pull, error) {\n \t\t\t&pull.Title,\n \t\t\t&pull.State,\n \t\t\t&pull.TargetBranch,\n-\t\t\t&pull.PullAt,\n \t\t\t&pull.Body,\n \t\t\t&pull.Rkey,\n \t\t\t&sourceBranch,\n@@ -487,7 +486,6 @@ func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {\n \t\t\ttitle,\n \t\t\tstate,\n \t\t\ttarget_branch,\n-\t\t\tpull_at,\n \t\t\trepo_at,\n \t\t\tbody,\n \t\t\trkey,\n@@ -510,7 +508,6 @@ func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {\n \t\t&pull.Title,\n \t\t&pull.State,\n \t\t&pull.TargetBranch,\n-\t\t&pull.PullAt,\n \t\t&pull.RepoAt,\n \t\t&pull.Body,\n \t\t&pull.Rkey,\ndiff --git a/appview/state/pull.go b/appview/state/pull.go\nindex 064f707..995cd11 100644\n--- a/appview/state/pull.go\n+++ b/appview/state/pull.go\n@@ -526,7 +526,7 @@ func (s *State) PullComment(w http.ResponseWriter, r *http.Request) {\n \t\t\tRecord: &lexutil.LexiconTypeDecoder{\n \t\t\t\tVal: &tangled.RepoPullComment{\n \t\t\t\t\tRepo:      &atUri,\n-\t\t\t\t\tPull:      pullAt,\n+\t\t\t\t\tPull:      string(pullAt),\n \t\t\t\t\tOwner:     &ownerDid,\n \t\t\t\t\tBody:      &body,\n \t\t\t\t\tCreatedAt: &createdAt,\n@@ -877,7 +877,7 @@ func (s *State) createPullRequest(\n \t\treturn\n \t}\n \n-\tatResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{\n+\t_, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{\n \t\tCollection: tangled.RepoPullNSID,\n \t\tRepo:       user.Did,\n \t\tRkey:       rkey,\n@@ -893,9 +893,8 @@ func (s *State) createPullRequest(\n \t\t},\n \t})\n \n-\terr = db.SetPullAt(s.db, f.RepoAt, pullId, atResp.Uri)\n \tif err != nil {\n-\t\tlog.Println(\"failed to get pull id\", err)\n+\t\tlog.Println(\"failed to create pull request\", err)\n \t\ts.pages.Notice(w, \"pull\", \"Failed to create pull request. Try again later.\")\n \t\treturn\n \t}\n-- \n2.43.0\n\n",
    "title": "appview: db: avoid setting PullAt",
    "pullId": 67,
    "source": {
      "branch": "remove-set-repo-at"
    },
    "targetRepo": "at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.repo/3liuighjy2h22",
    "targetBranch": "master"
  }
}