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: bump sourceRev for stacks without causing resubmits

this gets noisy really quickly when the stack is rebased. now, the only
things that can cause a resubmit are: reauthoring commit messages or
modifying the patch itself.

authored by

oppiliappan and committed by
Tangled
b3941e39 ca2bb4cd

+71 -2
+25
appview/db/pulls.go
··· 947 947 return err 948 948 } 949 949 950 + // Only used when stacking to update contents in the event of a rebase (the interdiff should be empty). 951 + // otherwise submissions are immutable 952 + func UpdatePull(e Execer, newPatch, sourceRev string, filters ...filter) error { 953 + var conditions []string 954 + var args []any 955 + 956 + args = append(args, sourceRev) 957 + args = append(args, newPatch) 958 + 959 + for _, filter := range filters { 960 + conditions = append(conditions, filter.Condition()) 961 + args = append(args, filter.arg) 962 + } 963 + 964 + whereClause := "" 965 + if conditions != nil { 966 + whereClause = " where " + strings.Join(conditions, " and ") 967 + } 968 + 969 + query := fmt.Sprintf("update pull_submissions set source_rev = ?, patch = ? %s", whereClause) 970 + _, err := e.Exec(query, args...) 971 + 972 + return err 973 + } 974 + 950 975 type PullCount struct { 951 976 Open int 952 977 Merged int
+46 -2
appview/state/pull.go
··· 260 260 latestSourceRev = top.Submissions[top.LastRoundNumber()].SourceRev 261 261 } 262 262 263 + log.Println(latestSourceRev, result.Branch.Hash) 264 + 263 265 if latestSourceRev != result.Branch.Hash { 264 - log.Println(latestSourceRev, result.Branch.Hash) 265 266 return pages.ShouldResubmit 266 267 } 267 268 ··· 1610 1609 patchutil.SortPatch(origFiles) 1611 1610 1612 1611 // text content of patch may be identical, but a jj rebase might have forwarded it 1613 - if patchutil.Equal(newFiles, origFiles) && origHeader.SHA == newHeader.SHA { 1612 + // 1613 + // we still need to update the hash in submission.Patch and submission.SourceRev 1614 + if patchutil.Equal(newFiles, origFiles) && 1615 + origHeader.Title == newHeader.Title && 1616 + origHeader.Body == newHeader.Body { 1614 1617 unchanged[op.ChangeId] = struct{}{} 1615 1618 } else { 1616 1619 updated[op.ChangeId] = struct{}{} ··· 1688 1683 1689 1684 record := op.AsRecord() 1690 1685 record.Patch = submission.Patch 1686 + 1687 + writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{ 1688 + RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{ 1689 + Collection: tangled.RepoPullNSID, 1690 + Rkey: op.Rkey, 1691 + Value: &lexutil.LexiconTypeDecoder{ 1692 + Val: &record, 1693 + }, 1694 + }, 1695 + }) 1696 + } 1697 + 1698 + // unchanged pulls are edited without starting a new round 1699 + // 1700 + // update source-revs & patches without advancing rounds 1701 + for changeId := range unchanged { 1702 + op, _ := origById[changeId] 1703 + np, _ := newById[changeId] 1704 + 1705 + origSubmission := op.Submissions[op.LastRoundNumber()] 1706 + newSubmission := np.Submissions[np.LastRoundNumber()] 1707 + 1708 + log.Println("moving unchanged change id : ", changeId) 1709 + 1710 + err := db.UpdatePull( 1711 + tx, 1712 + newSubmission.Patch, 1713 + newSubmission.SourceRev, 1714 + db.FilterEq("id", origSubmission.ID), 1715 + ) 1716 + 1717 + if err != nil { 1718 + log.Println("failed to update pull", err, op.PullId) 1719 + s.pages.Notice(w, "pull-resubmit-error", "Failed to resubmit pull request. Try again later.") 1720 + return 1721 + } 1722 + 1723 + record := op.AsRecord() 1724 + record.Patch = newSubmission.Patch 1691 1725 1692 1726 writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{ 1693 1727 RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{