mirror of
https://github.com/go-gitea/gitea
synced 2024-08-18 13:20:51 +02:00
* Change pull description text * move duplicated code into helper function
This commit is contained in:
parent
fcca037576
commit
e1266a19c8
@ -179,14 +179,30 @@ func checkPullInfo(ctx *context.Context) *models.Issue {
|
|||||||
return issue
|
return issue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setMergeTarget(ctx *context.Context, pull *models.PullRequest) {
|
||||||
|
if ctx.Repo.Owner.Name == pull.HeadUserName {
|
||||||
|
ctx.Data["HeadTarget"] = pull.HeadBranch
|
||||||
|
} else if pull.HeadRepo == nil {
|
||||||
|
ctx.Data["HeadTarget"] = pull.HeadUserName + ":" + pull.HeadBranch
|
||||||
|
} else {
|
||||||
|
ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadRepo.Name + ":" + pull.HeadBranch
|
||||||
|
}
|
||||||
|
ctx.Data["BaseTarget"] = pull.BaseBranch
|
||||||
|
}
|
||||||
|
|
||||||
// PrepareMergedViewPullInfo show meta information for a merged pull request view page
|
// PrepareMergedViewPullInfo show meta information for a merged pull request view page
|
||||||
func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) {
|
func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) {
|
||||||
pull := issue.PullRequest
|
pull := issue.PullRequest
|
||||||
ctx.Data["HasMerged"] = true
|
|
||||||
ctx.Data["HeadTarget"] = issue.PullRequest.HeadUserName + "/" + pull.HeadBranch
|
|
||||||
ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
if err = pull.GetHeadRepo(); err != nil {
|
||||||
|
ctx.Handle(500, "GetHeadRepo", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setMergeTarget(ctx, pull)
|
||||||
|
ctx.Data["HasMerged"] = true
|
||||||
|
|
||||||
ctx.Data["NumCommits"], err = ctx.Repo.GitRepo.CommitsCountBetween(pull.MergeBase, pull.MergedCommitID)
|
ctx.Data["NumCommits"], err = ctx.Repo.GitRepo.CommitsCountBetween(pull.MergeBase, pull.MergedCommitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "Repo.GitRepo.CommitsCountBetween", err)
|
ctx.Handle(500, "Repo.GitRepo.CommitsCountBetween", err)
|
||||||
@ -204,19 +220,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.PullReq
|
|||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
pull := issue.PullRequest
|
pull := issue.PullRequest
|
||||||
|
|
||||||
ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch
|
var err error
|
||||||
ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch
|
|
||||||
|
|
||||||
var (
|
|
||||||
headGitRepo *git.Repository
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
if err = pull.GetHeadRepo(); err != nil {
|
if err = pull.GetHeadRepo(); err != nil {
|
||||||
ctx.Handle(500, "GetHeadRepo", err)
|
ctx.Handle(500, "GetHeadRepo", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setMergeTarget(ctx, pull)
|
||||||
|
|
||||||
|
var headGitRepo *git.Repository
|
||||||
if pull.HeadRepo != nil {
|
if pull.HeadRepo != nil {
|
||||||
headGitRepo, err = git.OpenRepository(pull.HeadRepo.RepoPath())
|
headGitRepo, err = git.OpenRepository(pull.HeadRepo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user