diff --git a/services/pull/compare.go b/services/pull/compare.go index 00a74f2972..ce9210b22d 100644 --- a/services/pull/compare.go +++ b/services/pull/compare.go @@ -57,6 +57,12 @@ func GetCompareInfo(ctx context.Context, baseRepo, headRepo *repo_model.Reposito compareInfo.MergeBase = compareInfo.BaseCommitID } + if baseRepo.ID != headRepo.ID { + if err := gitrepo.FetchRemoteCommit(ctx, headRepo, baseRepo, compareInfo.BaseCommitID); err != nil { + return nil, fmt.Errorf("FetchRemoteCommit: %w", err) + } + } + // Count number of changed files. // This probably should be removed as we need to use shortstat elsewhere // Now there is git diff --shortstat but this appears to be slower than simply iterating with --nameonly