diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-05-18 10:37:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-18 10:37:49 +0800 |
commit | c385dcc26b0da7fc1c245a1da316551cb6585ad3 (patch) | |
tree | 849ebbdf9ee3dbe2cf99842f26b1bf4ca7426172 /routers | |
parent | 96b412bb875f534e37b9af3d9e71842a2dadb6e0 (diff) | |
download | gitea-c385dcc26b0da7fc1c245a1da316551cb6585ad3.tar.gz gitea-c385dcc26b0da7fc1c245a1da316551cb6585ad3.zip |
Fix index produces problem when issues/pulls deleted (#6973)
* fix index produces problem when issues/pulls deleted
* fix tests
* fix tests
* fix tests
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/pull.go | 8 | ||||
-rw-r--r-- | routers/repo/pull.go | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index dda8387913..f53ab4b8f3 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -251,9 +251,15 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption deadlineUnix = util.TimeStamp(form.Deadline.Unix()) } + maxIndex, err := models.GetMaxIndexOfIssue(repo.ID) + if err != nil { + ctx.ServerError("GetPatch", err) + return + } + prIssue := &models.Issue{ RepoID: repo.ID, - Index: repo.NextIssueIndex(), + Index: maxIndex + 1, Title: form.Title, PosterID: ctx.User.ID, Poster: ctx.User, diff --git a/routers/repo/pull.go b/routers/repo/pull.go index d1e2f0b0b3..412750dd55 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -946,9 +946,15 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) return } + maxIndex, err := models.GetMaxIndexOfIssue(repo.ID) + if err != nil { + ctx.ServerError("GetPatch", err) + return + } + pullIssue := &models.Issue{ RepoID: repo.ID, - Index: repo.NextIssueIndex(), + Index: maxIndex + 1, Title: form.Title, PosterID: ctx.User.ID, Poster: ctx.User, |