aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/pull.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/pull.go')
-rw-r--r--routers/repo/pull.go34
1 files changed, 21 insertions, 13 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 92538945b0..e4fd19ee49 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -273,8 +273,8 @@ func checkPullInfo(ctx *context.Context) *models.Issue {
return nil
}
- if err = issue.PullRequest.GetHeadRepo(); err != nil {
- ctx.ServerError("GetHeadRepo", err)
+ if err = issue.PullRequest.LoadHeadRepo(); err != nil {
+ ctx.ServerError("LoadHeadRepo", err)
return nil
}
@@ -313,7 +313,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) *git.C
if err != nil {
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
ctx.Data["IsPullRequestBroken"] = true
- ctx.Data["BaseTarget"] = "deleted"
+ ctx.Data["BaseTarget"] = pull.BaseBranch
ctx.Data["NumCommits"] = 0
ctx.Data["NumFiles"] = 0
return nil
@@ -332,13 +332,13 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
repo := ctx.Repo.Repository
pull := issue.PullRequest
- if err := pull.GetHeadRepo(); err != nil {
- ctx.ServerError("GetHeadRepo", err)
+ if err := pull.LoadHeadRepo(); err != nil {
+ ctx.ServerError("LoadHeadRepo", err)
return nil
}
- if err := pull.GetBaseRepo(); err != nil {
- ctx.ServerError("GetBaseRepo", err)
+ if err := pull.LoadBaseRepo(); err != nil {
+ ctx.ServerError("LoadBaseRepo", err)
return nil
}
@@ -432,7 +432,15 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
if pull.HeadRepo == nil || !headBranchExist || headBranchSha != sha {
ctx.Data["IsPullRequestBroken"] = true
- ctx.Data["HeadTarget"] = "deleted"
+ if pull.IsSameRepo() {
+ ctx.Data["HeadTarget"] = pull.HeadBranch
+ } else {
+ if pull.HeadRepo == nil {
+ ctx.Data["HeadTarget"] = "<deleted>:" + pull.HeadBranch
+ } else {
+ ctx.Data["HeadTarget"] = pull.HeadRepo.OwnerName + ":" + pull.HeadBranch
+ }
+ }
}
compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(),
@@ -440,7 +448,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
if err != nil {
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
ctx.Data["IsPullRequestBroken"] = true
- ctx.Data["BaseTarget"] = "deleted"
+ ctx.Data["BaseTarget"] = pull.BaseBranch
ctx.Data["NumCommits"] = 0
ctx.Data["NumFiles"] = 0
return nil
@@ -976,15 +984,15 @@ func CleanUpPullRequest(ctx *context.Context) {
return
}
- if err := pr.GetHeadRepo(); err != nil {
- ctx.ServerError("GetHeadRepo", err)
+ if err := pr.LoadHeadRepo(); err != nil {
+ ctx.ServerError("LoadHeadRepo", err)
return
} else if pr.HeadRepo == nil {
// Forked repository has already been deleted
ctx.NotFound("CleanUpPullRequest", nil)
return
- } else if err = pr.GetBaseRepo(); err != nil {
- ctx.ServerError("GetBaseRepo", err)
+ } else if err = pr.LoadBaseRepo(); err != nil {
+ ctx.ServerError("LoadBaseRepo", err)
return
} else if err = pr.HeadRepo.GetOwner(); err != nil {
ctx.ServerError("HeadRepo.GetOwner", err)