summaryrefslogtreecommitdiffstats
path: root/modules/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 /modules/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 'modules/repository')
-rw-r--r--modules/repository/push.go18
1 files changed, 0 insertions, 18 deletions
diff --git a/modules/repository/push.go b/modules/repository/push.go
index 1fa711b359..aa1552351d 100644
--- a/modules/repository/push.go
+++ b/modules/repository/push.go
@@ -4,10 +4,8 @@
package repository
import (
- "context"
"strings"
- repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
)
@@ -96,19 +94,3 @@ func (opts *PushUpdateOptions) RefName() string {
func (opts *PushUpdateOptions) RepoFullName() string {
return opts.RepoUserName + "/" + opts.RepoName
}
-
-// IsForcePush detect if a push is a force push
-func IsForcePush(ctx context.Context, opts *PushUpdateOptions) (bool, error) {
- if !opts.IsUpdateBranch() {
- return false, nil
- }
-
- output, _, err := git.NewCommand(ctx, "rev-list", "--max-count=1").AddDynamicArguments(opts.OldCommitID, "^"+opts.NewCommitID).
- RunStdString(&git.RunOpts{Dir: repo_model.RepoPath(opts.RepoUserName, opts.RepoName)})
- if err != nil {
- return false, err
- } else if len(output) > 0 {
- return true, nil
- }
- return false, nil
-}