diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-11-23 23:08:40 -0300 |
---|---|---|
committer | Antoine GIRARD <sapk@users.noreply.github.com> | 2019-11-24 03:08:40 +0100 |
commit | 1270e2ad85e7e700bb13492586c6e3fe8499b0d5 (patch) | |
tree | cf45f1ad27293e082af029344f7c34fef8f576e8 | |
parent | 29fa3a0f686241892fcb729cdad11640c4e0b340 (diff) | |
download | gitea-1270e2ad85e7e700bb13492586c6e3fe8499b0d5.tar.gz gitea-1270e2ad85e7e700bb13492586c6e3fe8499b0d5.zip |
Create PR on Current Repository by Default (#8670) (#9141)
* 'update'
* Send push tag event when release created
* send tag create event while release created in UI
* update to go v1.13
* fix gofmt error
* fix #8576 create pull request on current repository by default
-rw-r--r-- | routers/repo/compare.go | 28 | ||||
-rw-r--r-- | templates/repo/diff/compare.tmpl | 7 | ||||
-rw-r--r-- | templates/repo/issue/list.tmpl | 2 |
3 files changed, 35 insertions, 2 deletions
diff --git a/routers/repo/compare.go b/routers/repo/compare.go index 2b66d3818d..9c41a8af3c 100644 --- a/routers/repo/compare.go +++ b/routers/repo/compare.go @@ -346,6 +346,30 @@ func PrepareCompareDiff( return false } +// parseBaseRepoInfo parse base repository if current repo is forked. +// The "base" here means the repository where current repo forks from, +// not the repository fetch from current URL. +func parseBaseRepoInfo(ctx *context.Context, repo *models.Repository) error { + if !repo.IsFork { + return nil + } + if err := repo.GetBaseRepo(); err != nil { + return err + } + if err := repo.BaseRepo.GetOwnerName(); err != nil { + return err + } + baseGitRepo, err := git.OpenRepository(models.RepoPath(repo.BaseRepo.OwnerName, repo.BaseRepo.Name)) + if err != nil { + return err + } + ctx.Data["BaseRepoBranches"], err = baseGitRepo.GetBranches() + if err != nil { + return err + } + return nil +} + // CompareDiff show different from one commit to another commit func CompareDiff(ctx *context.Context) { headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx) @@ -353,6 +377,10 @@ func CompareDiff(ctx *context.Context) { return } defer headGitRepo.Close() + if err := parseBaseRepoInfo(ctx, headRepo); err != nil { + ctx.ServerError("parseBaseRepoInfo", err) + return + } nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch) if ctx.Written() { diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 1c8942d42f..50a51c44ac 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -28,6 +28,11 @@ {{range .Branches}} <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{EscapePound .}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound $.HeadBranch}}">{{$.BaseName}}:{{.}}</div> {{end}} + {{if .Repository.IsFork}} + {{range .BaseRepoBranches}} + <div class="item" data-url="{{$.PullRequestCtx.BaseRepo.Link}}/compare/{{EscapePound .}}...{{$.HeadUser.Name}}:{{EscapePound $.HeadBranch}}">{{$.PullRequestCtx.BaseRepo.OwnerName}}:{{.}}</div> + {{end}} + {{end}} </div> </div> </div> @@ -54,7 +59,7 @@ {{if .IsNothingToCompare}} <div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div> - {{else if .PageIsComparePull}} + {{else if .PageIsComparePull}} {{if .HasPullRequest}} <div class="ui segment"> {{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}} diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 5f39575499..6af8311313 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -14,7 +14,7 @@ {{if .PageIsIssueList}} <a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a> {{else}} - <a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.PullRequestCtx.BaseRepo.Link}}/compare/{{.PullRequestCtx.BaseRepo.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .PullRequestCtx.BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}:{{end}}{{.Repository.DefaultBranch | EscapePound}}{{end}}">{{.i18n.Tr "repo.pulls.new"}}</a> + <a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.Repository.Link}}/compare/{{.Repository.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .PullRequestCtx.BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}:{{end}}{{.Repository.DefaultBranch | EscapePound}}{{end}}">{{.i18n.Tr "repo.pulls.new"}}</a> {{end}} </div> {{else}} |