···
33
-
"github.com/bluekeyes/go-gitdiff/gitdiff"
comatproto "github.com/bluesky-social/indigo/api/atproto"
lexutil "github.com/bluesky-social/indigo/lex/util"
indigoxrpc "github.com/bluesky-social/indigo/xrpc"
···
// commits that got deleted: corresponding pull is closed
// commits that got added: new pull is created
// commits that got updated: corresponding pull is resubmitted & new round begins
1931
-
// for commits that were unchanged: no changes, parent-change-id is updated as necessary
additions := make(map[string]*models.Pull)
deletions := make(map[string]*models.Pull)
1934
-
unchanged := make(map[string]struct{})
updated := make(map[string]struct{})
// pulls in orignal stack but not in new one
···
for _, np := range newStack {
if op, ok := origById[np.ChangeId]; ok {
// pull exists in both stacks
1956
-
// TODO: can we avoid reparse?
1957
-
origFiles, origHeaderStr, _ := gitdiff.Parse(strings.NewReader(op.LatestPatch()))
1958
-
newFiles, newHeaderStr, _ := gitdiff.Parse(strings.NewReader(np.LatestPatch()))
1960
-
origHeader, _ := gitdiff.ParsePatchHeader(origHeaderStr)
1961
-
newHeader, _ := gitdiff.ParsePatchHeader(newHeaderStr)
1963
-
patchutil.SortPatch(newFiles)
1964
-
patchutil.SortPatch(origFiles)
1966
-
// text content of patch may be identical, but a jj rebase might have forwarded it
1968
-
// we still need to update the hash in submission.Patch and submission.SourceRev
1969
-
if patchutil.Equal(newFiles, origFiles) &&
1970
-
origHeader.Title == newHeader.Title &&
1971
-
origHeader.Body == newHeader.Body {
1972
-
unchanged[op.ChangeId] = struct{}{}
1974
-
updated[op.ChangeId] = struct{}{}
1952
+
updated[op.ChangeId] = struct{}{}
···
2067
-
// unchanged pulls are edited without starting a new round
2069
-
// update source-revs & patches without advancing rounds
2070
-
for changeId := range unchanged {
2071
-
op, _ := origById[changeId]
2072
-
np, _ := newById[changeId]
2074
-
origSubmission := op.Submissions[op.LastRoundNumber()]
2075
-
newSubmission := np.Submissions[np.LastRoundNumber()]
2077
-
log.Println("moving unchanged change id : ", changeId)
2079
-
err := db.UpdatePull(
2081
-
newSubmission.Patch,
2082
-
newSubmission.SourceRev,
2083
-
db.FilterEq("id", origSubmission.ID),
2087
-
log.Println("failed to update pull", err, op.PullId)
2088
-
s.pages.Notice(w, "pull-resubmit-error", "Failed to resubmit pull request. Try again later.")
2092
-
record := op.AsRecord()
2093
-
record.Patch = newSubmission.Patch
2095
-
writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
2096
-
RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{
2097
-
Collection: tangled.RepoPullNSID,
2099
-
Value: &lexutil.LexiconTypeDecoder{
// update parent-change-id relations for the entire stack
for _, p := range newStack {
err := db.SetPullParentChangeId(