Просмотр исходного кода

Merge branch 'develop' of https://github.com/tanapoln/gogs into develop

Unknwon 8 лет назад
Родитель
Сommit
44ed991726

+ 1 - 1
README.md

@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
 
 ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
 
-##### Current tip version: 0.9.102 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions or submit a task on [alpha stage automated binary building system](https://build.gogs.io/))
+##### Current tip version: 0.9.103 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions or submit a task on [alpha stage automated binary building system](https://build.gogs.io/))
 
 | Web | UI  | Preview  |
 |:-------------:|:-------:|:-------:|

+ 1 - 0
cmd/web.go

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

+ 2 - 0
conf/locale/locale_en-US.ini

@@ -580,6 +580,8 @@ 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
+pulls.delete_branch_has_new_commits = Branch cannot be deleted because it has new commits after mergence.
 
 milestones.new = New Milestone
 milestones.open_tab = %d Open

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.9.102.1220"
+const APP_VER = "0.9.103.1221"
 
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
modules/bindata/bindata.go


+ 1 - 1
public/config.codekit

@@ -1,6 +1,6 @@
 {
 "CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
-"creatorBuild": "19115",
+"creatorBuild": "19127",
 "files": {
 	"\/css\/github.min.css": {
 		"fileType": 16,

+ 39 - 0
routers/repo/branch.go

@@ -5,8 +5,11 @@
 package repo
 
 import (
+	"github.com/gogits/git-module"
+
 	"github.com/gogits/gogs/modules/base"
 	"github.com/gogits/gogs/modules/context"
+	"github.com/gogits/gogs/modules/log"
 )
 
 const (
@@ -29,3 +32,39 @@ func Branches(ctx *context.Context) {
 	ctx.Data["Branches"] = brs
 	ctx.HTML(200, BRANCH)
 }
+
+func DeleteBranchPost(ctx *context.Context) {
+	branchName := ctx.Params(":name")
+	commitID := ctx.Query("commit")
+
+	defer func() {
+		redirectTo := ctx.Query("redirect_to")
+		if len(redirectTo) == 0 {
+			redirectTo = ctx.Repo.RepoLink
+		}
+		ctx.Redirect(redirectTo)
+	}()
+
+	if !ctx.Repo.GitRepo.IsBranchExist(branchName) {
+		return
+	}
+	if len(commitID) > 0 {
+		branchCommitID, err := ctx.Repo.GitRepo.GetBranchCommitID(branchName)
+		if err != nil {
+			log.Error(4, "GetBranchCommitID: %v", err)
+			return
+		}
+
+		if branchCommitID != commitID {
+			ctx.Flash.Error(ctx.Tr("repo.pulls.delete_branch_has_new_commits"))
+			return
+		}
+	}
+
+	if err := ctx.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
+		Force: false,
+	}); err != nil {
+		log.Error(4, "DeleteBranch: %v", err)
+		return
+	}
+}

+ 9 - 0
routers/repo/issue.go

@@ -629,6 +629,15 @@ func ViewIssue(ctx *context.Context) {
 		}
 	}
 
+	if issue.IsPull && issue.PullRequest.HasMerged {
+		pull := issue.PullRequest
+		ctx.Data["IsPullBranchDeletable"] = pull.BaseRepoID == pull.HeadRepoID &&
+			ctx.Repo.IsWriter() && ctx.Repo.GitRepo.IsBranchExist(pull.HeadBranch)
+
+		deleteBranchUrl := ctx.Repo.RepoLink + "/branches/" + pull.HeadBranch + "/delete"
+		ctx.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchUrl, pull.MergedCommitID, ctx.Data["Link"])
+	}
+
 	ctx.Data["Participants"] = participants
 	ctx.Data["NumParticipants"] = len(participants)
 	ctx.Data["Issue"] = issue

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.9.102.1220
+0.9.103.1221

+ 10 - 1
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"}}
@@ -265,7 +274,7 @@
 					<div class="item">
 						<a class="ui label {{if not .IsChecked}}hide{{end}}" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}">{{.Name}}</a>
 					</div>
-					
+
 				{{end}}
 			</div>
 

Некоторые файлы не были показаны из-за большого количества измененных файлов