diff --git a/appview/db/pulls.go b/appview/db/pulls.go index da6e086e..53622ab6 100644 --- a/appview/db/pulls.go +++ b/appview/db/pulls.go @@ -235,8 +235,6 @@ func (s PullSubmission) AsFormatPatch() []patchutil.FormatPatch { } func NewPull(tx *sql.Tx, pull *Pull) error { - defer tx.Rollback() - _, err := tx.Exec(` insert or ignore into repo_pull_seqs (repo_at, next_pull_id) values (?, 1) @@ -291,15 +289,7 @@ func NewPull(tx *sql.Tx, pull *Pull) error { insert into pull_submissions (pull_id, repo_at, round_number, patch, source_rev) values (?, ?, ?, ?, ?) `, pull.PullId, pull.RepoAt, 0, pull.Submissions[0].Patch, pull.Submissions[0].SourceRev) - if err != nil { - return err - } - - if err := tx.Commit(); err != nil { - return err - } - - return nil + return err } func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error) { diff --git a/appview/state/pull.go b/appview/state/pull.go index 7a08b697..1fc229da 100644 --- a/appview/state/pull.go +++ b/appview/state/pull.go @@ -903,13 +903,18 @@ func (s *State) createPullRequest( }, }, }) - if err != nil { log.Println("failed to create pull request", err) s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.") return } + if err = tx.Commit(); err != nil { + log.Println("failed to create pull request", err) + s.pages.Notice(w, "pull", "Failed to create pull request. Try again later.") + return + } + s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pullId)) }