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