diff options
author | Unknwon <u@gogs.io> | 2015-10-04 20:54:06 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-10-04 20:54:06 -0400 |
commit | 215920772ab8d84418e982ee1de8986f911fe3c1 (patch) | |
tree | b3cd6bce4ae72ca497cf9835ea2f7b6cd96bff4b /routers/repo | |
parent | 02d3b662654d1627ad510b7b330c016e97a7d1af (diff) | |
download | gitea-215920772ab8d84418e982ee1de8986f911fe3c1.tar.gz gitea-215920772ab8d84418e982ee1de8986f911fe3c1.zip |
save PR info as patch and minor fix on PR
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/pull.go | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c1eec7cc2f..40c83351ca 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -187,16 +187,22 @@ func PrepareViewPullInfo(ctx *middleware.Context, pull *models.Issue) *git.PullR ctx.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBarcnh ctx.Data["BaseTarget"] = ctx.Repo.Owner.Name + "/" + pull.BaseBranch - headRepoPath, err := pull.HeadRepo.RepoPath() - if err != nil { - ctx.Handle(500, "HeadRepo.RepoPath", err) - return nil - } + var ( + headGitRepo *git.Repository + err error + ) + if pull.HeadRepo != nil { + headRepoPath, err := pull.HeadRepo.RepoPath() + if err != nil { + ctx.Handle(500, "HeadRepo.RepoPath", err) + return nil + } - headGitRepo, err := git.OpenRepository(headRepoPath) - if err != nil { - ctx.Handle(500, "OpenRepository", err) - return nil + headGitRepo, err = git.OpenRepository(headRepoPath) + if err != nil { + ctx.Handle(500, "OpenRepository", err) + return nil + } } if pull.HeadRepo == nil || !headGitRepo.IsBranchExist(pull.HeadBarcnh) { @@ -530,18 +536,18 @@ func CompareAndPullRequest(ctx *middleware.Context) { return } - pr, err := models.GetUnmergedPullRequest(headRepo.ID, ctx.Repo.Repository.ID, headBranch, baseBranch) - if err != nil { - if !models.IsErrPullRequestNotExist(err) { - ctx.Handle(500, "GetUnmergedPullRequest", err) - return - } - } else { - ctx.Data["HasPullRequest"] = true - ctx.Data["PullRequest"] = pr - ctx.HTML(200, COMPARE_PULL) - return - } + // pr, err := models.GetUnmergedPullRequest(headRepo.ID, ctx.Repo.Repository.ID, headBranch, baseBranch) + // if err != nil { + // if !models.IsErrPullRequestNotExist(err) { + // ctx.Handle(500, "GetUnmergedPullRequest", err) + // return + // } + // } else { + // ctx.Data["HasPullRequest"] = true + // ctx.Data["PullRequest"] = pr + // ctx.HTML(200, COMPARE_PULL) + // return + // } nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch) if ctx.Written() { @@ -575,7 +581,7 @@ func CompareAndPullRequestPost(ctx *middleware.Context, form auth.CreateIssueFor return } - patch, err := headGitRepo.GetPatch(models.RepoPath(repo.Owner.Name, repo.Name), baseBranch, headBranch) + patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch) if err != nil { ctx.Handle(500, "GetPatch", err) return |