Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/pulls: do not mutate submissions in stacked resubmits

patch equality is cool, but insufficent to represent the change of a
change. the underlying context could have changed.

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Tangled
4247ce35 196d3df7

+1 -63
+1 -63
appview/pulls/pulls.go
··· 30 30 "tangled.org/core/tid" 31 31 "tangled.org/core/types" 32 32 33 - "github.com/bluekeyes/go-gitdiff/gitdiff" 34 33 comatproto "github.com/bluesky-social/indigo/api/atproto" 35 34 lexutil "github.com/bluesky-social/indigo/lex/util" 36 35 indigoxrpc "github.com/bluesky-social/indigo/xrpc" ··· 1926 1927 // commits that got deleted: corresponding pull is closed 1927 1928 // commits that got added: new pull is created 1928 1929 // commits that got updated: corresponding pull is resubmitted & new round begins 1929 - // 1930 - // for commits that were unchanged: no changes, parent-change-id is updated as necessary 1931 1930 additions := make(map[string]*models.Pull) 1932 1931 deletions := make(map[string]*models.Pull) 1933 - unchanged := make(map[string]struct{}) 1934 1932 updated := make(map[string]struct{}) 1935 1933 1936 1934 // pulls in orignal stack but not in new one ··· 1949 1953 for _, np := range newStack { 1950 1954 if op, ok := origById[np.ChangeId]; ok { 1951 1955 // pull exists in both stacks 1952 - // TODO: can we avoid reparse? 1953 - origFiles, origHeaderStr, _ := gitdiff.Parse(strings.NewReader(op.LatestPatch())) 1954 - newFiles, newHeaderStr, _ := gitdiff.Parse(strings.NewReader(np.LatestPatch())) 1955 - 1956 - origHeader, _ := gitdiff.ParsePatchHeader(origHeaderStr) 1957 - newHeader, _ := gitdiff.ParsePatchHeader(newHeaderStr) 1958 - 1959 - patchutil.SortPatch(newFiles) 1960 - patchutil.SortPatch(origFiles) 1961 - 1962 - // text content of patch may be identical, but a jj rebase might have forwarded it 1963 - // 1964 - // we still need to update the hash in submission.Patch and submission.SourceRev 1965 - if patchutil.Equal(newFiles, origFiles) && 1966 - origHeader.Title == newHeader.Title && 1967 - origHeader.Body == newHeader.Body { 1968 - unchanged[op.ChangeId] = struct{}{} 1969 - } else { 1970 - updated[op.ChangeId] = struct{}{} 1971 - } 1956 + updated[op.ChangeId] = struct{}{} 1972 1957 } 1973 1958 } 1974 1959 ··· 2029 2052 2030 2053 record := op.AsRecord() 2031 2054 record.Patch = submission.Patch 2032 - 2033 - writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{ 2034 - RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{ 2035 - Collection: tangled.RepoPullNSID, 2036 - Rkey: op.Rkey, 2037 - Value: &lexutil.LexiconTypeDecoder{ 2038 - Val: &record, 2039 - }, 2040 - }, 2041 - }) 2042 - } 2043 - 2044 - // unchanged pulls are edited without starting a new round 2045 - // 2046 - // update source-revs & patches without advancing rounds 2047 - for changeId := range unchanged { 2048 - op, _ := origById[changeId] 2049 - np, _ := newById[changeId] 2050 - 2051 - origSubmission := op.Submissions[op.LastRoundNumber()] 2052 - newSubmission := np.Submissions[np.LastRoundNumber()] 2053 - 2054 - log.Println("moving unchanged change id : ", changeId) 2055 - 2056 - err := db.UpdatePull( 2057 - tx, 2058 - newSubmission.Patch, 2059 - newSubmission.SourceRev, 2060 - db.FilterEq("id", origSubmission.ID), 2061 - ) 2062 - 2063 - if err != nil { 2064 - log.Println("failed to update pull", err, op.PullId) 2065 - s.pages.Notice(w, "pull-resubmit-error", "Failed to resubmit pull request. Try again later.") 2066 - return 2067 - } 2068 - 2069 - record := op.AsRecord() 2070 - record.Patch = newSubmission.Patch 2071 2055 2072 2056 writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{ 2073 2057 RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{