···2930 "github.com/bluekeyes/go-gitdiff/gitdiff"
31 comatproto "github.com/bluesky-social/indigo/api/atproto"
032 lexutil "github.com/bluesky-social/indigo/lex/util"
33 indigoxrpc "github.com/bluesky-social/indigo/xrpc"
34 "github.com/go-chi/chi/v5"
···1836 newStack, err := newStack(f, user, targetBranch, patch, pull.PullSource, stackId)
1837 if err != nil {
1838 log.Println("failed to create resubmitted stack", err)
1839- s.pages.Notice(w, "pull-merge-error", "Failed to merge pull request. Try again later.")
1840 return
1841 }
18421843 // find the diff between the stacks, first, map them by changeId
01844 origById := make(map[string]*models.Pull)
1845 newById := make(map[string]*models.Pull)
001846 for _, p := range origStack {
1847 origById[p.ChangeId] = p
00001848 }
1849 for _, p := range newStack {
0000001850 newById[p.ChangeId] = p
1851 }
1852···1894 // we still need to update the hash in submission.Patch and submission.SourceRev
1895 if patchutil.Equal(newFiles, origFiles) &&
1896 origHeader.Title == newHeader.Title &&
1897- origHeader.Body == newHeader.Body {
01898 unchanged[op.ChangeId] = struct{}{}
1899 } else {
1900 updated[op.ChangeId] = struct{}{}
···19781979 record := op.AsRecord()
1980 record.Patch = submission.Patch
019811982 writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
1983 RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{
···2343 // the stack is identified by a UUID
2344 var stack models.Stack
2345 parentChangeId := ""
02346 for _, fp := range formatPatches {
2347 // all patches must have a jj change-id
2348 changeId, err := fp.ChangeId()
···23732374 StackId: stackId,
2375 ChangeId: changeId,
02376 ParentChangeId: parentChangeId,
2377 }
23782379 stack = append(stack, &pull)
23802381 parentChangeId = changeId
00002382 }
23832384 return stack, nil
···2930 "github.com/bluekeyes/go-gitdiff/gitdiff"
31 comatproto "github.com/bluesky-social/indigo/api/atproto"
32+ "github.com/bluesky-social/indigo/atproto/syntax"
33 lexutil "github.com/bluesky-social/indigo/lex/util"
34 indigoxrpc "github.com/bluesky-social/indigo/xrpc"
35 "github.com/go-chi/chi/v5"
···1837 newStack, err := newStack(f, user, targetBranch, patch, pull.PullSource, stackId)
1838 if err != nil {
1839 log.Println("failed to create resubmitted stack", err)
1840+ s.pages.Notice(w, "pull-resubmit-error", "Failed to merge pull request. Try again later.")
1841 return
1842 }
18431844 // find the diff between the stacks, first, map them by changeId
1845+1846 origById := make(map[string]*models.Pull)
1847 newById := make(map[string]*models.Pull)
1848+ chIdToAtUri := make(map[string]*syntax.ATURI)
1849+1850 for _, p := range origStack {
1851 origById[p.ChangeId] = p
1852+1853+ // build map from change id to existing at uris (ignore error as it shouldnt be possible here)
1854+ pAtUri, _ := syntax.ParseATURI(fmt.Sprintf("at://%s/%s/%s", user.Did, tangled.RepoPullNSID, p.Rkey))
1855+ chIdToAtUri[p.ChangeId] = &pAtUri
1856 }
1857 for _, p := range newStack {
1858+ // if change id has already been given a PR use its at uri instead of the newly created (and thus incorrect)
1859+ // one made by newStack
1860+ if ppAt, ok := chIdToAtUri[p.ParentChangeId]; ok {
1861+ p.ParentAt = ppAt
1862+ }
1863+1864 newById[p.ChangeId] = p
1865 }
1866···1908 // we still need to update the hash in submission.Patch and submission.SourceRev
1909 if patchutil.Equal(newFiles, origFiles) &&
1910 origHeader.Title == newHeader.Title &&
1911+ origHeader.Body == newHeader.Body &&
1912+ op.ParentChangeId == np.ParentChangeId {
1913 unchanged[op.ChangeId] = struct{}{}
1914 } else {
1915 updated[op.ChangeId] = struct{}{}
···19931994 record := op.AsRecord()
1995 record.Patch = submission.Patch
1996+ record.StackInfo.Parent = (*string)(np.ParentAt)
19971998 writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
1999 RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{
···2359 // the stack is identified by a UUID
2360 var stack models.Stack
2361 parentChangeId := ""
2362+ var parentAt *syntax.ATURI = nil
2363 for _, fp := range formatPatches {
2364 // all patches must have a jj change-id
2365 changeId, err := fp.ChangeId()
···23902391 StackId: stackId,
2392 ChangeId: changeId,
2393+ ParentAt: parentAt,
2394 ParentChangeId: parentChangeId,
2395 }
23962397 stack = append(stack, &pull)
23982399 parentChangeId = changeId
2400+ // this is a bit of an ugly way to create the ATURI but its the best we can do with the data flow here
2401+ // (igore error as it shouldnt be possible here)
2402+ parsedParentAt, _ := syntax.ParseATURI(fmt.Sprintf("at://%s/%s/%s", user.Did, tangled.RepoPullNSID, pull.Rkey));
2403+ parentAt = &parsedParentAt
2404 }
24052406 return stack, nil