From cf0f451c37496c84795e98191a20350e0f5be35c Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 11 Feb 2017 12:00:29 +0800 Subject: Add delete branch track on pull request comments (#888) * add delete branch track on pull request comments * don't change vendor --- routers/repo/branch.go | 12 +++++++++++- routers/repo/issue.go | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'routers/repo') diff --git a/routers/repo/branch.go b/routers/repo/branch.go index 104d459a7d..d040f2a560 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -6,6 +6,7 @@ package repo import ( "code.gitea.io/git" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" @@ -70,12 +71,21 @@ func DeleteBranchPost(ctx *context.Context) { } if err := ctx.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{ - Force: false, + Force: true, }); err != nil { log.Error(4, "DeleteBranch: %v", err) ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", fullBranchName)) return } + issueID := ctx.QueryInt64("issue_id") + if issueID > 0 { + if err := models.AddDeletePRBranchComment(ctx.User, ctx.Repo.Repository, issueID, branchName); err != nil { + log.Error(4, "DeleteBranch: %v", err) + ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", fullBranchName)) + return + } + } + ctx.Flash.Success(ctx.Tr("repo.branch.deletion_success", fullBranchName)) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 17c3b56c2e..e9b60175f3 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -635,7 +635,8 @@ func ViewIssue(ctx *context.Context) { } else if ctx.User.IsWriterOfRepo(pull.HeadRepo) { canDelete = true deleteBranchURL := pull.HeadRepo.Link() + "/branches/" + pull.HeadBranch + "/delete" - ctx.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchURL, pull.MergedCommitID, ctx.Data["Link"]) + ctx.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s&issue_id=%d", + deleteBranchURL, pull.MergedCommitID, ctx.Data["Link"], issue.ID) } } -- cgit v1.2.3