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/branch.go | |
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/branch.go')
-rw-r--r-- | routers/repo/branch.go | 19 |
1 files changed, 19 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) +} |