mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Provide button to delete merged pull request (#441)
* provide button to delete merged pull request * golint fix
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user