diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-25 23:27:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-25 23:27:25 +0800 |
commit | 4b7594d9fa0da67cbc8df74ee1711043168ebbbd (patch) | |
tree | eed4cbedb522844a93645cc8e0d48d904b694ad1 /routers/repo | |
parent | d4924d45d6d4e991240d207a834d8d6709781449 (diff) | |
download | gitea-4b7594d9fa0da67cbc8df74ee1711043168ebbbd.tar.gz gitea-4b7594d9fa0da67cbc8df74ee1711043168ebbbd.zip |
Provide button to delete merged pull request (#441)
* provide button to delete merged pull request
* golint fix
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/branch.go | 19 | ||||
-rw-r--r-- | routers/repo/issue.go | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/routers/repo/branch.go b/routers/repo/branch.go index fcb6efd010..c3336e598c 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -5,6 +5,7 @@ package repo import ( + "code.gitea.io/git" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" ) @@ -30,3 +31,21 @@ func Branches(ctx *context.Context) { ctx.Data["Branches"] = brs ctx.HTML(200, tplBranch) } + +// DeleteBranchPost responses for delete merged branch +func DeleteBranchPost(ctx *context.Context) { + branchName := ctx.Params(":name") + + if err := ctx.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{ + Force: false, + }); err != nil { + ctx.Handle(500, "DeleteBranch", err) + return + } + + redirectTo := ctx.Query("redirect_to") + if len(redirectTo) == 0 { + redirectTo = ctx.Repo.RepoLink + } + ctx.Redirect(redirectTo) +} diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 1cf5722ed1..104c893136 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -661,6 +661,15 @@ func ViewIssue(ctx *context.Context) { } } + if issue.IsPull { + pull := issue.PullRequest + ctx.Data["IsPullBranchDeletable"] = ctx.Repo.IsWriter() && ctx.Repo.GitRepo.IsBranchExist(pull.HeadBranch) + + deleteBranchURL := ctx.Repo.RepoLink + "/branches/" + pull.HeadBranch + "/delete" + queryParams := "?redirect_to=" + ctx.Data["Link"].(string) + ctx.Data["DeleteBranchLink"] = deleteBranchURL + queryParams + } + ctx.Data["Participants"] = participants ctx.Data["NumParticipants"] = len(participants) ctx.Data["Issue"] = issue |