* Change pull description text * move duplicated code into helper function
This commit is contained in:
parent
fcca037576
commit
e1266a19c8
1 changed files with 23 additions and 11 deletions
|
@ -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 a new issue