mirror of
https://github.com/go-gitea/gitea
synced 2026-02-03 11:10:40 +00:00
Fix bug when list pull request commits (#36485)
Fix #36483 In git log/rev-list, the "..." syntax represents the symmetric difference between two references, which is different from the meaning of "..." in git diff (where it implies diffing from the merge base). For listing PR commits, we must use `merge-base..head` to include only the commits introduced by the head branch. Otherwise, commits newly pushed to the base branch would also be included, which is incorrect.
This commit is contained in:
@@ -84,7 +84,11 @@ func GetCompareInfo(ctx context.Context, baseRepo, headRepo *repo_model.Reposito
|
|||||||
|
|
||||||
// We have a common base - therefore we know that ... should work
|
// We have a common base - therefore we know that ... should work
|
||||||
if !fileOnly {
|
if !fileOnly {
|
||||||
compareInfo.Commits, err = headGitRepo.ShowPrettyFormatLogToList(ctx, compareInfo.BaseCommitID+compareInfo.CompareSeparator+compareInfo.HeadCommitID)
|
// In git log/rev-list, the "..." syntax represents the symmetric difference between two references,
|
||||||
|
// which is different from the meaning of "..." in git diff (where it implies diffing from the merge base).
|
||||||
|
// For listing PR commits, we must use merge-base..head to include only the commits introduced by the head branch.
|
||||||
|
// Otherwise, commits newly pushed to the base branch would also be included, which is incorrect.
|
||||||
|
compareInfo.Commits, err = headGitRepo.ShowPrettyFormatLogToList(ctx, compareInfo.MergeBase+".."+compareInfo.HeadCommitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("ShowPrettyFormatLogToList: %w", err)
|
return nil, fmt.Errorf("ShowPrettyFormatLogToList: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user