Refactor pull request view (1) (#37380)
Refactor preparePullViewPullInfo and related functions, split them into small ones: * preparePullViewPullInfo creates PullRequestViewInfo struct * if the PR is merged: prepareView**Merged**PullInfo * if the PR is open: prepareView**Open**PullInfo In prepareViewMergedPullInfo and preparePullViewFillInfo: call preparePullView**FillInfo** consistnently preparePullViewFillInfo calls preparePullViewFill**CompareInfo** and preparePullViewFill**CommitStatusInfo**
This commit is contained in:
@@ -1175,7 +1175,7 @@ func parseCompareInfo(ctx *context.APIContext, compareParam string) (result *git
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return compareInfo, closer
|
||||
return &compareInfo, closer
|
||||
}
|
||||
|
||||
// UpdatePullRequest merge PR's baseBranch into headBranch
|
||||
@@ -1419,7 +1419,6 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
var compareInfo *git_service.CompareInfo
|
||||
baseGitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
@@ -1427,6 +1426,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
||||
}
|
||||
defer closer.Close()
|
||||
|
||||
var compareInfo git_service.CompareInfo
|
||||
if pr.HasMerged {
|
||||
compareInfo, err = git_service.GetCompareInfo(ctx, pr.BaseRepo, pr.BaseRepo, baseGitRepo, git.RefName(pr.MergeBase), git.RefName(pr.GetGitHeadRefName()), false, false)
|
||||
} else {
|
||||
@@ -1552,7 +1552,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||
|
||||
baseGitRepo := ctx.Repo.GitRepo
|
||||
|
||||
var compareInfo *git_service.CompareInfo
|
||||
var compareInfo git_service.CompareInfo
|
||||
if pr.HasMerged {
|
||||
compareInfo, err = git_service.GetCompareInfo(ctx, pr.BaseRepo, pr.BaseRepo, baseGitRepo, git.RefName(pr.MergeBase), git.RefName(pr.GetGitHeadRefName()), false, false)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user