Browse Source

provide button to delete merged pull request

pull/3225/head
Tanapol Nearunchorn 8 years ago
parent
commit
73fedc7275
  1. 1
      cmd/web.go
  2. 1
      conf/locale/locale_en-US.ini
  3. 794
      modules/bindata/bindata.go
  4. 19
      routers/repo/branch.go
  5. 9
      routers/repo/issue.go
  6. 9
      templates/repo/issue/view_content.tmpl

1
cmd/web.go

@ -543,6 +543,7 @@ func runWeb(ctx *cli.Context) error {
}, context.RepoRef())
// m.Get("/branches", repo.Branches)
m.Post("/branches/:name/delete", reqSignIn, reqRepoWriter, repo.DeleteBranchPost)
m.Group("/wiki", func() {
m.Get("/?:page", repo.Wiki)

1
conf/locale/locale_en-US.ini

@ -580,6 +580,7 @@ pulls.cannot_auto_merge_desc = This pull request can't be merged automatically b
pulls.cannot_auto_merge_helper = Please merge manually in order to resolve the conflicts.
pulls.merge_pull_request = Merge Pull Request
pulls.open_unmerged_pull_exists = `You can't perform reopen operation because there is already an open pull request (#%d) from same repository with same merge information and is waiting for merging.`
pulls.delete_branch = Delete Branch
milestones.new = New Milestone
milestones.open_tab = %d Open

794
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

19
routers/repo/branch.go

@ -5,6 +5,8 @@
package repo
import (
"github.com/gogits/git-module"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/context"
)
@ -29,3 +31,20 @@ func Branches(ctx *context.Context) {
ctx.Data["Branches"] = brs
ctx.HTML(200, 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)
}

9
routers/repo/issue.go

@ -629,6 +629,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

9
templates/repo/issue/view_content.tmpl

@ -163,6 +163,15 @@
<div class="item text purple">
{{$.i18n.Tr "repo.pulls.has_merged"}}
</div>
{{if .IsPullBranchDeletable}}
<div class="ui divider"></div>
<div>
<form class="ui form" action="{{.DeleteBranchLink}}" method="post">
{{.CsrfTokenHtml}}
<button class="ui red button">{{$.i18n.Tr "repo.pulls.delete_branch"}}</button>
</form>
</div>
{{end}}
{{else if .Issue.IsClosed}}
<div class="item text grey">
{{$.i18n.Tr "repo.pulls.reopen_to_merge"}}

Loading…
Cancel
Save