forked from tangled.org/core
this repo has no description

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.

Changed files
+71 -2
appview
db
state
+25
appview/db/pulls.go
···
return err
}
+
// Only used when stacking to update contents in the event of a rebase (the interdiff should be empty).
+
// otherwise submissions are immutable
+
func UpdatePull(e Execer, newPatch, sourceRev string, filters ...filter) error {
+
var conditions []string
+
var args []any
+
+
args = append(args, sourceRev)
+
args = append(args, newPatch)
+
+
for _, filter := range filters {
+
conditions = append(conditions, filter.Condition())
+
args = append(args, filter.arg)
+
}
+
+
whereClause := ""
+
if conditions != nil {
+
whereClause = " where " + strings.Join(conditions, " and ")
+
}
+
+
query := fmt.Sprintf("update pull_submissions set source_rev = ?, patch = ? %s", whereClause)
+
_, err := e.Exec(query, args...)
+
+
return err
+
}
+
type PullCount struct {
Open int
Merged int
+46 -2
appview/state/pull.go
···
latestSourceRev = top.Submissions[top.LastRoundNumber()].SourceRev
}
+
log.Println(latestSourceRev, result.Branch.Hash)
+
if latestSourceRev != result.Branch.Hash {
-
log.Println(latestSourceRev, result.Branch.Hash)
return pages.ShouldResubmit
}
···
patchutil.SortPatch(origFiles)
// text content of patch may be identical, but a jj rebase might have forwarded it
-
if patchutil.Equal(newFiles, origFiles) && origHeader.SHA == newHeader.SHA {
+
//
+
// we still need to update the hash in submission.Patch and submission.SourceRev
+
if patchutil.Equal(newFiles, origFiles) &&
+
origHeader.Title == newHeader.Title &&
+
origHeader.Body == newHeader.Body {
unchanged[op.ChangeId] = struct{}{}
} else {
updated[op.ChangeId] = struct{}{}
···
record := op.AsRecord()
record.Patch = submission.Patch
+
+
writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
+
RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{
+
Collection: tangled.RepoPullNSID,
+
Rkey: op.Rkey,
+
Value: &lexutil.LexiconTypeDecoder{
+
Val: &record,
+
},
+
},
+
})
+
}
+
+
// unchanged pulls are edited without starting a new round
+
//
+
// update source-revs & patches without advancing rounds
+
for changeId := range unchanged {
+
op, _ := origById[changeId]
+
np, _ := newById[changeId]
+
+
origSubmission := op.Submissions[op.LastRoundNumber()]
+
newSubmission := np.Submissions[np.LastRoundNumber()]
+
+
log.Println("moving unchanged change id : ", changeId)
+
+
err := db.UpdatePull(
+
tx,
+
newSubmission.Patch,
+
newSubmission.SourceRev,
+
db.FilterEq("id", origSubmission.ID),
+
)
+
+
if err != nil {
+
log.Println("failed to update pull", err, op.PullId)
+
s.pages.Notice(w, "pull-resubmit-error", "Failed to resubmit pull request. Try again later.")
+
return
+
}
+
+
record := op.AsRecord()
+
record.Patch = newSubmission.Patch
writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{