···29293030 "github.com/bluekeyes/go-gitdiff/gitdiff"
3131 comatproto "github.com/bluesky-social/indigo/api/atproto"
3232+ "github.com/bluesky-social/indigo/atproto/syntax"
3233 lexutil "github.com/bluesky-social/indigo/lex/util"
3334 indigoxrpc "github.com/bluesky-social/indigo/xrpc"
3435 "github.com/go-chi/chi/v5"
···18361837 newStack, err := newStack(f, user, targetBranch, patch, pull.PullSource, stackId)
18371838 if err != nil {
18381839 log.Println("failed to create resubmitted stack", err)
18391839- s.pages.Notice(w, "pull-merge-error", "Failed to merge pull request. Try again later.")
18401840+ s.pages.Notice(w, "pull-resubmit-error", "Failed to merge pull request. Try again later.")
18401841 return
18411842 }
1842184318431844 // find the diff between the stacks, first, map them by changeId
18451845+18441846 origById := make(map[string]*models.Pull)
18451847 newById := make(map[string]*models.Pull)
18481848+ chIdToAtUri := make(map[string]*syntax.ATURI)
18491849+18461850 for _, p := range origStack {
18471851 origById[p.ChangeId] = p
18521852+18531853+ // build map from change id to existing at uris (ignore error as it shouldnt be possible here)
18541854+ pAtUri, _ := syntax.ParseATURI(fmt.Sprintf("at://%s/%s/%s", user.Did, tangled.RepoPullNSID, p.Rkey))
18551855+ chIdToAtUri[p.ChangeId] = &pAtUri
18481856 }
18491857 for _, p := range newStack {
18581858+ // if change id has already been given a PR use its at uri instead of the newly created (and thus incorrect)
18591859+ // one made by newStack
18601860+ if ppAt, ok := chIdToAtUri[p.ParentChangeId]; ok {
18611861+ p.ParentAt = ppAt
18621862+ }
18631863+18501864 newById[p.ChangeId] = p
18511865 }
18521866···18941908 // we still need to update the hash in submission.Patch and submission.SourceRev
18951909 if patchutil.Equal(newFiles, origFiles) &&
18961910 origHeader.Title == newHeader.Title &&
18971897- origHeader.Body == newHeader.Body {
19111911+ origHeader.Body == newHeader.Body &&
19121912+ op.ParentChangeId == np.ParentChangeId {
18981913 unchanged[op.ChangeId] = struct{}{}
18991914 } else {
19001915 updated[op.ChangeId] = struct{}{}
···1978199319791994 record := op.AsRecord()
19801995 record.Patch = submission.Patch
19961996+ record.StackInfo.Parent = (*string)(np.ParentAt)
1981199719821998 writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
19831999 RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{
···23432359 // the stack is identified by a UUID
23442360 var stack models.Stack
23452361 parentChangeId := ""
23622362+ var parentAt *syntax.ATURI = nil
23462363 for _, fp := range formatPatches {
23472364 // all patches must have a jj change-id
23482365 changeId, err := fp.ChangeId()
···2373239023742391 StackId: stackId,
23752392 ChangeId: changeId,
23932393+ ParentAt: parentAt,
23762394 ParentChangeId: parentChangeId,
23772395 }
2378239623792397 stack = append(stack, &pull)
2380239823812399 parentChangeId = changeId
24002400+ // this is a bit of an ugly way to create the ATURI but its the best we can do with the data flow here
24012401+ // (igore error as it shouldnt be possible here)
24022402+ parsedParentAt, _ := syntax.ParseATURI(fmt.Sprintf("at://%s/%s/%s", user.Did, tangled.RepoPullNSID, pull.Rkey));
24032403+ parentAt = &parsedParentAt
23822404 }
2383240523842406 return stack, nil