+4
-2
appview/db/pulls.go
+4
-2
appview/db/pulls.go
···
590
590
return err
591
591
}
592
592
593
-
func ResubmitPull(e Execer, pull *models.Pull, newPatch, sourceRev string) error {
593
+
func ResubmitPull(e Execer, pull *models.Pull) error {
594
+
newPatch := pull.LatestPatch()
595
+
newSourceRev := pull.LatestSha()
594
596
newRoundNumber := len(pull.Submissions)
595
597
_, err := e.Exec(`
596
598
insert into pull_submissions (pull_at, round_number, patch, source_rev)
597
599
values (?, ?, ?, ?)
598
-
`, pull.PullAt(), newRoundNumber, newPatch, sourceRev)
600
+
`, pull.PullAt(), newRoundNumber, newPatch, newSourceRev)
599
601
600
602
return err
601
603
}
+6
-15
appview/models/pull.go
+6
-15
appview/models/pull.go
···
84
84
func (p Pull) AsRecord() tangled.RepoPull {
85
85
var source *tangled.RepoPull_Source
86
86
if p.PullSource != nil {
87
-
s := p.PullSource.AsRecord()
88
-
source = &s
87
+
source = &tangled.RepoPull_Source{}
88
+
source.Branch = p.PullSource.Branch
89
89
source.Sha = p.LatestSha()
90
+
if p.PullSource.RepoAt != nil {
91
+
s := p.PullSource.Repo.RepoAt().String()
92
+
source.Repo = &s
93
+
}
90
94
}
91
95
92
96
record := tangled.RepoPull{
···
109
113
110
114
// optionally populate this for reverse mappings
111
115
Repo *Repo
112
-
}
113
-
114
-
func (p PullSource) AsRecord() tangled.RepoPull_Source {
115
-
var repoAt *string
116
-
if p.RepoAt != nil {
117
-
s := p.RepoAt.String()
118
-
repoAt = &s
119
-
}
120
-
record := tangled.RepoPull_Source{
121
-
Branch: p.Branch,
122
-
Repo: repoAt,
123
-
}
124
-
return record
125
116
}
126
117
127
118
type PullSubmission struct {
+10
-9
appview/pulls/pulls.go
+10
-9
appview/pulls/pulls.go
···
415
415
416
416
targetBranch := branchResp
417
417
418
-
latestSourceRev := pull.Submissions[pull.LastRoundNumber()].SourceRev
418
+
latestSourceRev := pull.LatestSha()
419
419
420
420
if pull.IsStacked() && stack != nil {
421
421
top := stack[0]
422
-
latestSourceRev = top.Submissions[top.LastRoundNumber()].SourceRev
422
+
latestSourceRev = top.LatestSha()
423
423
}
424
424
425
425
if latestSourceRev != targetBranch.Hash {
···
1811
1811
1812
1812
// validate sourceRev if branch/fork based
1813
1813
if pull.IsBranchBased() || pull.IsForkBased() {
1814
-
if sourceRev == pull.Submissions[pull.LastRoundNumber()].SourceRev {
1814
+
if sourceRev == pull.LatestSha() {
1815
1815
s.pages.Notice(w, "resubmit-error", "This branch has not changed since the last submission.")
1816
1816
return
1817
1817
}
···
1825
1825
}
1826
1826
defer tx.Rollback()
1827
1827
1828
-
err = db.ResubmitPull(tx, pull, patch, sourceRev)
1828
+
pull.Submissions = append(pull.Submissions, &models.PullSubmission{
1829
+
Patch: patch,
1830
+
SourceRev: sourceRev,
1831
+
})
1832
+
err = db.ResubmitPull(tx, pull)
1829
1833
if err != nil {
1830
1834
log.Println("failed to create pull request", err)
1831
1835
s.pages.Notice(w, "resubmit-error", "Failed to create pull request. Try again later.")
···
2016
2020
continue
2017
2021
}
2018
2022
2019
-
submission := np.Submissions[np.LastRoundNumber()]
2020
-
2021
2023
// resubmit the old pull
2022
-
err := db.ResubmitPull(tx, op, submission.Patch, submission.SourceRev)
2024
+
err := db.ResubmitPull(tx, np)
2023
2025
2024
2026
if err != nil {
2025
2027
log.Println("failed to update pull", err, op.PullId)
···
2027
2029
return
2028
2030
}
2029
2031
2030
-
record := op.AsRecord()
2031
-
record.Patch = submission.Patch
2032
+
record := np.AsRecord()
2032
2033
2033
2034
writes = append(writes, &comatproto.RepoApplyWrites_Input_Writes_Elem{
2034
2035
RepoApplyWrites_Update: &comatproto.RepoApplyWrites_Update{