Create PR on Current Repository by Default (#8670)

* '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
tokarchuk/v1.17
Benno 5 years ago committed by Lunny Xiao
parent 7bb817e6d1
commit e6706df49d
  1. 28
      routers/repo/compare.go
  2. 7
      templates/repo/diff/compare.tmpl
  3. 2
      templates/repo/issue/list.tmpl

@ -339,12 +339,40 @@ func PrepareCompareDiff(
return false 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 // CompareDiff show different from one commit to another commit
func CompareDiff(ctx *context.Context) { func CompareDiff(ctx *context.Context) {
headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx) headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
if ctx.Written() { if ctx.Written() {
return return
} }
if err := parseBaseRepoInfo(ctx, headRepo); err != nil {
ctx.ServerError("parseBaseRepoInfo", err)
return
}
nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch) nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch)
if ctx.Written() { if ctx.Written() {

@ -28,6 +28,11 @@
{{range .Branches}} {{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> <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}} {{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> </div>
</div> </div>
@ -54,7 +59,7 @@
{{if .IsNothingToCompare}} {{if .IsNothingToCompare}}
<div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div> <div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div>
{{else if .PageIsComparePull}} {{else if .PageIsComparePull}}
{{if .HasPullRequest}} {{if .HasPullRequest}}
<div class="ui segment"> <div class="ui segment">
{{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}} {{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}}

@ -14,7 +14,7 @@
{{if .PageIsIssueList}} {{if .PageIsIssueList}}
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a> <a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
{{else}} {{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}} {{end}}
</div> </div>
{{else}} {{else}}

Loading…
Cancel
Save