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
···
"github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/bluesky-social/indigo/atproto/syntax"
"tangled.sh/tangled.sh/core/patchutil"
"tangled.sh/tangled.sh/core/types"
)
···
RepoAt syntax.ATURI
OwnerDid string
Rkey string
-
PullAt syntax.ATURI
// content
Title string
···
func (p *Pull) LatestPatch() string {
latestSubmission := p.Submissions[p.LastRoundNumber()]
return latestSubmission.Patch
}
func (p *Pull) LastRoundNumber() int {
···
return nil
}
-
func SetPullAt(e Execer, repoAt syntax.ATURI, pullId int, pullAt string) error {
-
_, err := e.Exec(`update pulls set pull_at = ? where repo_at = ? and pull_id = ?`, pullAt, repoAt, pullId)
-
return err
-
}
-
-
func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (string, error) {
-
var pullAt string
-
err := e.QueryRow(`select pull_at from pulls where repo_at = ? and pull_id = ?`, repoAt, pullId).Scan(&pullAt)
-
return pullAt, err
}
func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) {
···
title,
state,
target_branch,
-
pull_at,
body,
rkey,
source_branch,
···
&pull.Title,
&pull.State,
&pull.TargetBranch,
-
&pull.PullAt,
&pull.Body,
&pull.Rkey,
&sourceBranch,
···
title,
state,
target_branch,
-
pull_at,
repo_at,
body,
rkey,
···
&pull.Title,
&pull.State,
&pull.TargetBranch,
-
&pull.PullAt,
&pull.RepoAt,
&pull.Body,
&pull.Rkey,
···
"github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/bluesky-social/indigo/atproto/syntax"
+
tangled "tangled.sh/tangled.sh/core/api/tangled"
"tangled.sh/tangled.sh/core/patchutil"
"tangled.sh/tangled.sh/core/types"
)
···
RepoAt syntax.ATURI
OwnerDid string
Rkey string
// content
Title string
···
func (p *Pull) LatestPatch() string {
latestSubmission := p.Submissions[p.LastRoundNumber()]
return latestSubmission.Patch
+
}
+
+
func (p *Pull) PullAt() syntax.ATURI {
+
return syntax.ATURI(fmt.Sprintf("at://%s/%s/%s", p.OwnerDid, tangled.RepoPullNSID, p.Rkey))
}
func (p *Pull) LastRoundNumber() int {
···
return nil
}
+
func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error) {
+
pull, err := GetPull(e, repoAt, pullId)
+
if err != nil {
+
return "", err
+
}
+
return pull.PullAt(), err
}
func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) {
···
title,
state,
target_branch,
body,
rkey,
source_branch,
···
&pull.Title,
&pull.State,
&pull.TargetBranch,
&pull.Body,
&pull.Rkey,
&sourceBranch,
···
title,
state,
target_branch,
repo_at,
body,
rkey,
···
&pull.Title,
&pull.State,
&pull.TargetBranch,
&pull.RepoAt,
&pull.Body,
&pull.Rkey,
+3 -4
appview/state/pull.go
···
Record: &lexutil.LexiconTypeDecoder{
Val: &tangled.RepoPullComment{
Repo: &atUri,
-
Pull: pullAt,
Owner: &ownerDid,
Body: &body,
CreatedAt: &createdAt,
···
return
}
-
atResp, err := comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
Collection: tangled.RepoPullNSID,
Repo: user.Did,
Rkey: rkey,
···
},
})
-
err = db.SetPullAt(s.db, f.RepoAt, pullId, atResp.Uri)
if err != nil {
-
log.Println("failed to get pull id", err)
s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.")
return
}
···
Record: &lexutil.LexiconTypeDecoder{
Val: &tangled.RepoPullComment{
Repo: &atUri,
+
Pull: string(pullAt),
Owner: &ownerDid,
Body: &body,
CreatedAt: &createdAt,
···
return
}
+
_, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{
Collection: tangled.RepoPullNSID,
Repo: user.Did,
Rkey: rkey,
···
},
})
if err != nil {
+
log.Println("failed to create pull request", err)
s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.")
return
}