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

appview: db: avoid setting PullAt

Changed files
+14 -18
appview
db
state
+11 -14
appview/db/pulls.go
··· 10 11 "github.com/bluekeyes/go-gitdiff/gitdiff" 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 "tangled.sh/tangled.sh/core/patchutil" 14 "tangled.sh/tangled.sh/core/types" 15 ) ··· 54 RepoAt syntax.ATURI 55 OwnerDid string 56 Rkey string 57 - PullAt syntax.ATURI 58 59 // content 60 Title string ··· 118 func (p *Pull) LatestPatch() string { 119 latestSubmission := p.Submissions[p.LastRoundNumber()] 120 return latestSubmission.Patch 121 } 122 123 func (p *Pull) LastRoundNumber() int { ··· 298 return nil 299 } 300 301 - func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error { 302 - _, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId) 303 - return err 304 - } 305 - 306 - func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) { 307 - var pullAt string 308 - err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt) 309 - return pullAt, err 310 } 311 312 func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) { ··· 326 title, 327 state, 328 target_branch, 329 - pull_at, 330 body, 331 rkey, 332 source_branch, ··· 351 &pull.Title, 352 &pull.State, 353 &pull.TargetBranch, 354 - &pull.PullAt, 355 &pull.Body, 356 &pull.Rkey, 357 &sourceBranch, ··· 487 title, 488 state, 489 target_branch, 490 - pull_at, 491 repo_at, 492 body, 493 rkey, ··· 510 &pull.Title, 511 &pull.State, 512 &pull.TargetBranch, 513 - &pull.PullAt, 514 &pull.RepoAt, 515 &pull.Body, 516 &pull.Rkey,
··· 10 11 "github.com/bluekeyes/go-gitdiff/gitdiff" 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 + tangled "tangled.sh/tangled.sh/core/api/tangled" 14 "tangled.sh/tangled.sh/core/patchutil" 15 "tangled.sh/tangled.sh/core/types" 16 ) ··· 55 RepoAt syntax.ATURI 56 OwnerDid string 57 Rkey string 58 59 // content 60 Title string ··· 118 func (p *Pull) LatestPatch() string { 119 latestSubmission := p.Submissions[p.LastRoundNumber()] 120 return latestSubmission.Patch 121 + } 122 + 123 + func (p *Pull) PullAt() syntax.ATURI { 124 + return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", p.OwnerDid, tangled.RepoPullNSID, p.Rkey)) 125 } 126 127 func (p *Pull) LastRoundNumber() int { ··· 302 return nil 303 } 304 305 + func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error) { 306 + pull, err := GetPull(e, repoAt, pullId) 307 + if err != nil { 308 + return "", err 309 + } 310 + return pull.PullAt(), err 311 } 312 313 func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) { ··· 327 title, 328 state, 329 target_branch, 330 body, 331 rkey, 332 source_branch, ··· 351 &pull.Title, 352 &pull.State, 353 &pull.TargetBranch, 354 &pull.Body, 355 &pull.Rkey, 356 &sourceBranch, ··· 486 title, 487 state, 488 target_branch, 489 repo_at, 490 body, 491 rkey, ··· 508 &pull.Title, 509 &pull.State, 510 &pull.TargetBranch, 511 &pull.RepoAt, 512 &pull.Body, 513 &pull.Rkey,
+3 -4
appview/state/pull.go
··· 526 Record: &lexutil.LexiconTypeDecoder{ 527 Val: &tangled.RepoPullComment{ 528 Repo: &atUri, 529 - Pull: pullAt, 530 Owner: &ownerDid, 531 Body: &body, 532 CreatedAt: &createdAt, ··· 877 return 878 } 879 880 - atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 881 Collection: tangled.RepoPullNSID, 882 Repo: user.Did, 883 Rkey: rkey, ··· 893 }, 894 }) 895 896 - err = db.SetPullAt(s.db, f.RepoAt, pullId, atResp.Uri) 897 if err != nil { 898 - log.Println("failed to get pull id", err) 899 s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.") 900 return 901 }
··· 526 Record: &lexutil.LexiconTypeDecoder{ 527 Val: &tangled.RepoPullComment{ 528 Repo: &atUri, 529 + Pull: string(pullAt), 530 Owner: &ownerDid, 531 Body: &body, 532 CreatedAt: &createdAt, ··· 877 return 878 } 879 880 + _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 881 Collection: tangled.RepoPullNSID, 882 Repo: user.Did, 883 Rkey: rkey, ··· 893 }, 894 }) 895 896 if err != nil { 897 + log.Println("failed to create pull request", err) 898 s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.") 899 return 900 }