修复:compare diff 为空
This commit is contained in:
parent
d9432b0b5a
commit
c13c3e269a
|
|
@ -48,7 +48,11 @@ func PrepareComapreDiff(
|
|||
|
||||
ctx.Data["CommitRepoLink"] = headRepo.Link()
|
||||
|
||||
headCommitID := headBranch
|
||||
beforeCommitID := compareInfo.MergeBase
|
||||
if compareInfo.DirectComparison() {
|
||||
beforeCommitID = compareInfo.BaseCommitID
|
||||
}
|
||||
headCommitID := compareInfo.HeadCommitID
|
||||
if ctx.Data["HeadIsCommit"] == false {
|
||||
if ctx.Data["HeadIsTag"] == true {
|
||||
headCommitID, err = headGitRepo.GetTagCommitID(headBranch)
|
||||
|
|
@ -73,8 +77,8 @@ func PrepareComapreDiff(
|
|||
gitRepo, _ := gitea_git.OpenRepository(ctx, repoPath)
|
||||
defer gitRepo.Close()
|
||||
|
||||
diff, err := gitdiff.GetDiffForAPI(ctx, gitRepo, &gitdiff.DiffOptions{
|
||||
BeforeCommitID: compareInfo.MergeBase,
|
||||
diff, err := gitdiff.GetDiffForAPI(ctx, compareInfo.HeadGitRepo, &gitdiff.DiffOptions{
|
||||
BeforeCommitID: beforeCommitID,
|
||||
AfterCommitID: headCommitID,
|
||||
SkipTo: ctx.FormString("skip-to"),
|
||||
MaxLines: setting.Git.MaxGitDiffLines,
|
||||
|
|
@ -88,7 +92,7 @@ func PrepareComapreDiff(
|
|||
return false
|
||||
}
|
||||
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ctx.Repo.Repository, gitRepo, compareInfo.MergeBase, headCommitID)
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, compareInfo.HeadRepo, compareInfo.HeadGitRepo, beforeCommitID, headCommitID)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return false
|
||||
|
|
@ -229,13 +233,13 @@ func CompareDiff(ctx *context.APIContext) {
|
|||
})
|
||||
} else {
|
||||
path := util.PathEscapeSegments(ctx.FormString("filepath"))
|
||||
headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
|
||||
headUser, _, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
defer headGitRepo.Close()
|
||||
|
||||
_ = PrepareComapreDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch, path)
|
||||
_ = PrepareComapreDiff(ctx, headUser, compareInfo.HeadRepo, compareInfo.HeadGitRepo, compareInfo, baseBranch, headBranch, path)
|
||||
|
||||
result := make([]CompareCommit, 0)
|
||||
for _, commit := range compareInfo.Commits {
|
||||
|
|
|
|||
Loading…
Reference in New Issue