diff options
author | Unknwon <u@gogs.io> | 2015-09-02 16:18:09 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-02 16:18:09 -0400 |
commit | 83dc2468f574e9cf83515e54268bdb4c03f6d98c (patch) | |
tree | 03499c31d850c1c0e4cb063b9cc70f9c1d2a063b /routers | |
parent | 842770d7fbc72789d6df885da7ec5a2d4070f25f (diff) | |
download | gitea-83dc2468f574e9cf83515e54268bdb4c03f6d98c.tar.gz gitea-83dc2468f574e9cf83515e54268bdb4c03f6d98c.zip |
finish initial version of pull request
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/issue.go | 42 | ||||
-rw-r--r-- | routers/repo/pull.go | 6 | ||||
-rw-r--r-- | routers/user/home.go | 54 |
3 files changed, 62 insertions, 40 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 631986877d..f6d6f32e32 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -55,8 +55,14 @@ func RetrieveLabels(ctx *middleware.Context) { } func Issues(ctx *middleware.Context) { - ctx.Data["Title"] = ctx.Tr("repo.issues") - ctx.Data["PageIsIssueList"] = true + isPullList := ctx.Params(":type") == "pulls" + if isPullList { + ctx.Data["Title"] = ctx.Tr("repo.pulls") + ctx.Data["PageIsPullList"] = true + } else { + ctx.Data["Title"] = ctx.Tr("repo.issues") + ctx.Data["PageIsIssueList"] = true + } viewType := ctx.Query("type") sortType := ctx.Query("sort") @@ -97,7 +103,15 @@ func Issues(ctx *middleware.Context) { selectLabels := ctx.Query("labels") milestoneID := ctx.QueryInt64("milestone") isShowClosed := ctx.Query("state") == "closed" - issueStats := models.GetIssueStats(repo.ID, uid, com.StrTo(selectLabels).MustInt64(), milestoneID, assigneeID, filterMode) + issueStats := models.GetIssueStats(&models.IssueStatsOptions{ + RepoID: repo.ID, + UserID: uid, + LabelID: com.StrTo(selectLabels).MustInt64(), + MilestoneID: milestoneID, + AssigneeID: assigneeID, + FilterMode: filterMode, + IsPull: isPullList, + }) page := ctx.QueryInt("page") if page <= 1 { @@ -113,8 +127,19 @@ func Issues(ctx *middleware.Context) { ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5) // Get issues. - issues, err := models.Issues(uid, assigneeID, repo.ID, posterID, milestoneID, - nil, page, isShowClosed, filterMode == models.FM_MENTION, selectLabels, sortType) + issues, err := models.Issues(&models.IssuesOptions{ + UserID: uid, + AssigneeID: assigneeID, + RepoID: repo.ID, + PosterID: posterID, + MilestoneID: milestoneID, + Page: page, + IsClosed: isShowClosed, + IsMention: filterMode == models.FM_MENTION, + IsPull: isPullList, + Labels: selectLabels, + SortType: sortType, + }) if err != nil { ctx.Handle(500, "Issues: %v", err) return @@ -188,6 +213,7 @@ func renderAttachmentSettings(ctx *middleware.Context) { ctx.Data["RequireDropzone"] = true ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes + ctx.Data["AttachmentMaxSize"] = setting.AttachmentMaxSize ctx.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles } @@ -324,7 +350,7 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { issue := &models.Issue{ RepoID: ctx.Repo.Repository.ID, - Index: int64(repo.NumIssues) + 1, + Index: int64(repo.NumIssues) + int64(repo.NumPulls) + 1, Name: form.Title, PosterID: ctx.User.Id, Poster: ctx.User, @@ -1096,7 +1122,3 @@ func DeleteMilestone(ctx *middleware.Context) { "redirect": ctx.Repo.RepoLink + "/milestones", }) } - -func PullRequest2(ctx *middleware.Context) { - ctx.HTML(200, "repo/pr2/list") -} diff --git a/routers/repo/pull.go b/routers/repo/pull.go index caa651c621..eb06becb8d 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -23,7 +23,6 @@ import ( const ( FORK base.TplName = "repo/pulls/fork" COMPARE_PULL base.TplName = "repo/pulls/compare" - PULLS base.TplName = "repo/pulls" PULL_COMMITS base.TplName = "repo/pulls/commits" PULL_FILES base.TplName = "repo/pulls/files" ) @@ -129,11 +128,6 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) { ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name) } -func Pulls(ctx *middleware.Context) { - ctx.Data["IsRepoToolbarPulls"] = true - ctx.HTML(200, PULLS) -} - func checkPullInfo(ctx *middleware.Context) *models.Issue { pull, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { diff --git a/routers/user/home.go b/routers/user/home.go index 95e0fc0fe0..8008889d49 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -20,7 +20,6 @@ import ( const ( DASHBOARD base.TplName = "user/dashboard/dashboard" - PULLS base.TplName = "user/dashboard/pulls" ISSUES base.TplName = "user/dashboard/issues" STARS base.TplName = "user/stars" PROFILE base.TplName = "user/profile" @@ -139,23 +138,15 @@ func Dashboard(ctx *middleware.Context) { ctx.HTML(200, DASHBOARD) } -func Pulls(ctx *middleware.Context) { - ctx.Data["Title"] = ctx.Tr("pull_requests") - ctx.Data["PageIsDashboard"] = true - ctx.Data["PageIsPulls"] = true - - if err := ctx.User.GetOrganizations(); err != nil { - ctx.Handle(500, "GetOrganizations", err) - return - } - ctx.Data["ContextUser"] = ctx.User - - ctx.HTML(200, PULLS) -} - func Issues(ctx *middleware.Context) { - ctx.Data["Title"] = ctx.Tr("issues") - ctx.Data["PageIsIssues"] = true + isPullList := ctx.Params(":type") == "pulls" + if isPullList { + ctx.Data["Title"] = ctx.Tr("pull_requests") + ctx.Data["PageIsPulls"] = true + } else { + ctx.Data["Title"] = ctx.Tr("issues") + ctx.Data["PageIsIssues"] = true + } ctxUser := getDashboardContextUser(ctx) if ctx.Written() { @@ -202,17 +193,24 @@ func Issues(ctx *middleware.Context) { repoIDs := make([]int64, 0, len(repos)) showRepos := make([]*models.Repository, 0, len(repos)) for _, repo := range repos { - if repo.NumIssues == 0 { + if (isPullList && repo.NumPulls == 0) || + (!isPullList && repo.NumIssues == 0) { continue } repoIDs = append(repoIDs, repo.ID) - repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues - allCount += repo.NumOpenIssues + + if isPullList { + allCount += repo.NumOpenPulls + repo.NumOpenIssues = repo.NumOpenPulls + repo.NumClosedIssues = repo.NumClosedPulls + } else { + allCount += repo.NumOpenIssues + } if filterMode != models.FM_ALL { // Calculate repository issue count with filter mode. - numOpen, numClosed := repo.IssueStats(ctxUser.Id, filterMode) + numOpen, numClosed := repo.IssueStats(ctxUser.Id, filterMode, isPullList) repo.NumOpenIssues, repo.NumClosedIssues = int(numOpen), int(numClosed) } @@ -224,7 +222,7 @@ func Issues(ctx *middleware.Context) { } ctx.Data["Repos"] = showRepos - issueStats := models.GetUserIssueStats(repoID, ctxUser.Id, repoIDs, filterMode) + issueStats := models.GetUserIssueStats(repoID, ctxUser.Id, repoIDs, filterMode, isPullList) issueStats.AllCount = int64(allCount) page := ctx.QueryInt("page") @@ -241,8 +239,16 @@ func Issues(ctx *middleware.Context) { ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5) // Get issues. - issues, err := models.Issues(ctxUser.Id, assigneeID, repoID, posterID, 0, - repoIDs, page, isShowClosed, false, "", "") + issues, err := models.Issues(&models.IssuesOptions{ + UserID: ctxUser.Id, + AssigneeID: assigneeID, + RepoID: repoID, + PosterID: posterID, + RepoIDs: repoIDs, + Page: page, + IsClosed: isShowClosed, + IsPull: isPullList, + }) if err != nil { ctx.Handle(500, "Issues: %v", err) return |