aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2023-03-09 19:14:22 +0100
committerGitHub <noreply@github.com>2023-03-09 12:14:22 -0600
commit8bdc0acf97f2fce504bf43ee3843be3c638dfd2f (patch)
tree96793bcab1db39bbfa4675fa43fcfb3c43a22629 /services/repository
parent689770c928ed46725e72ddaa2e988c52e44c2975 (diff)
downloadgitea-8bdc0acf97f2fce504bf43ee3843be3c638dfd2f.tar.gz
gitea-8bdc0acf97f2fce504bf43ee3843be3c638dfd2f.zip
Fix pull request update showing too many commits with multiple branches (#22856)
When the base repository contains multiple branches with the same commits as the base branch, pull requests can show a long list of commits already in the base branch as having been added. What this is supposed to do is exclude commits already in the base branch. But the mechansim to do so assumed a commit only exists in a single branch. Now use `git rev-list A B --not branchName` instead of filtering commits afterwards. The logic to detect if there was a force push also was wrong for multiple branches. If the old commit existed in any branch in the base repository it would assume there was no force push. Instead check if the old commit is an ancestor of the new commit.
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/push.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/services/repository/push.go b/services/repository/push.go
index cdf030396f..4b574e3440 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -206,12 +206,12 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
return fmt.Errorf("newCommit.CommitsBeforeUntil: %w", err)
}
- isForce, err := repo_module.IsForcePush(ctx, opts)
+ isForcePush, err := newCommit.IsForcePush(opts.OldCommitID)
if err != nil {
- log.Error("isForcePush %s:%s failed: %v", repo.FullName(), branch, err)
+ log.Error("IsForcePush %s:%s failed: %v", repo.FullName(), branch, err)
}
- if isForce {
+ if isForcePush {
log.Trace("Push %s is a force push", opts.NewCommitID)
cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))