mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-08 09:53:59 +01:00
This adds a per-repository default PR base branch and wires it through PR entry points. It updates compare links and recently pushed branch prompts to respect the configured base branch, and prevents auto-merge cleanup from deleting the configured base branch on same-repo PRs. ## Behavior changes - New PR compare links on repo home/issue list and branch list honor the configured default PR base branch. - The "recently pushed new branches" prompt now compares against the configured base branch. - Auto-merge branch cleanup skips deleting the configured base branch (same-repo PRs only). --------- Signed-off-by: Louis <116039387+tototomate123@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
33 lines
852 B
Go
33 lines
852 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package repo
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/unit"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDefaultTargetBranchSelection(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
ctx := t.Context()
|
|
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1})
|
|
|
|
assert.Equal(t, repo.DefaultBranch, repo.GetPullRequestTargetBranch(ctx))
|
|
|
|
repo.Units = nil
|
|
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
|
|
assert.NoError(t, err)
|
|
prConfig := prUnit.PullRequestsConfig()
|
|
prConfig.DefaultTargetBranch = "branch2"
|
|
prUnit.Config = prConfig
|
|
assert.NoError(t, UpdateRepoUnit(ctx, prUnit))
|
|
repo.Units = nil
|
|
assert.Equal(t, "branch2", repo.GetPullRequestTargetBranch(ctx))
|
|
}
|