Merge 3906649be7 into 7be5935c55
This commit is contained in:
commit
e15b5b981c
|
|
@ -340,30 +340,23 @@ func ViewPullCommits(ctx *context.Context) {
|
||||||
pull := issue.PullRequest
|
pull := issue.PullRequest
|
||||||
|
|
||||||
var commits *list.List
|
var commits *list.List
|
||||||
|
var prInfo *git.PullRequestInfo
|
||||||
if pull.HasMerged {
|
if pull.HasMerged {
|
||||||
prInfo := PrepareMergedViewPullInfo(ctx, issue)
|
prInfo = PrepareMergedViewPullInfo(ctx, issue)
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
} else if prInfo == nil {
|
|
||||||
ctx.NotFound("ViewPullCommits", nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
|
||||||
commits = prInfo.Commits
|
|
||||||
} else {
|
} else {
|
||||||
prInfo := PrepareViewPullInfo(ctx, issue)
|
prInfo = PrepareViewPullInfo(ctx, issue)
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
} else if prInfo == nil {
|
|
||||||
ctx.NotFound("ViewPullCommits", nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.Data["Username"] = pull.HeadUserName
|
|
||||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
|
||||||
commits = prInfo.Commits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
} else if prInfo == nil {
|
||||||
|
ctx.NotFound("ViewPullCommits", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
|
commits = prInfo.Commits
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
commits = models.ParseCommitsWithSignature(commits)
|
commits = models.ParseCommitsWithSignature(commits)
|
||||||
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
commits = models.ParseCommitsWithStatus(commits, ctx.Repo.Repository)
|
||||||
|
|
@ -392,63 +385,36 @@ func ViewPullFiles(ctx *context.Context) {
|
||||||
)
|
)
|
||||||
|
|
||||||
var headTarget string
|
var headTarget string
|
||||||
|
var prInfo *git.PullRequestInfo
|
||||||
if pull.HasMerged {
|
if pull.HasMerged {
|
||||||
prInfo := PrepareMergedViewPullInfo(ctx, issue)
|
prInfo = PrepareMergedViewPullInfo(ctx, issue)
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
} else if prInfo == nil {
|
|
||||||
ctx.NotFound("ViewPullFiles", nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
diffRepoPath = ctx.Repo.GitRepo.Path
|
|
||||||
gitRepo = ctx.Repo.GitRepo
|
|
||||||
|
|
||||||
headCommitID, err := gitRepo.GetRefCommitID(pull.GetGitRefName())
|
|
||||||
if err != nil {
|
|
||||||
ctx.ServerError("GetRefCommitID", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
startCommitID = prInfo.MergeBase
|
|
||||||
endCommitID = headCommitID
|
|
||||||
|
|
||||||
headTarget = path.Join(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
|
||||||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
|
||||||
} else {
|
} else {
|
||||||
prInfo := PrepareViewPullInfo(ctx, issue)
|
prInfo = PrepareViewPullInfo(ctx, issue)
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
} else if prInfo == nil {
|
|
||||||
ctx.NotFound("ViewPullFiles", nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
headRepoPath := models.RepoPath(pull.HeadUserName, pull.HeadRepo.Name)
|
|
||||||
|
|
||||||
headGitRepo, err := git.OpenRepository(headRepoPath)
|
|
||||||
if err != nil {
|
|
||||||
ctx.ServerError("OpenRepository", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
headCommitID, err := headGitRepo.GetBranchCommitID(pull.HeadBranch)
|
|
||||||
if err != nil {
|
|
||||||
ctx.ServerError("GetBranchCommitID", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
diffRepoPath = headRepoPath
|
|
||||||
startCommitID = prInfo.MergeBase
|
|
||||||
endCommitID = headCommitID
|
|
||||||
gitRepo = headGitRepo
|
|
||||||
|
|
||||||
headTarget = path.Join(pull.HeadUserName, pull.HeadRepo.Name)
|
|
||||||
ctx.Data["Username"] = pull.HeadUserName
|
|
||||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
} else if prInfo == nil {
|
||||||
|
ctx.NotFound("ViewPullFiles", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
diffRepoPath = ctx.Repo.GitRepo.Path
|
||||||
|
gitRepo = ctx.Repo.GitRepo
|
||||||
|
|
||||||
|
headCommitID, err := gitRepo.GetRefCommitID(pull.GetGitRefName())
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetRefCommitID", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
startCommitID = prInfo.MergeBase
|
||||||
|
endCommitID = headCommitID
|
||||||
|
|
||||||
|
headTarget = path.Join(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||||
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
|
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||||
|
|
||||||
diff, err := models.GetDiffRange(diffRepoPath,
|
diff, err := models.GetDiffRange(diffRepoPath,
|
||||||
startCommitID, endCommitID, setting.Git.MaxGitDiffLines,
|
startCommitID, endCommitID, setting.Git.MaxGitDiffLines,
|
||||||
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user