1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Add DefaultMergeStyle option to repository (#14789)

Fixes #12293
This commit is contained in:
parnic
2021-03-27 09:55:40 -05:00
committed by GitHub
parent 6b836ac5f7
commit f4d27498bd
11 changed files with 70 additions and 2 deletions

View File

@@ -71,6 +71,7 @@ func innerToRepo(repo *models.Repository, mode models.AccessMode, isParent bool)
allowRebase := false
allowRebaseMerge := false
allowSquash := false
defaultMergeStyle := models.MergeStyleMerge
if unit, err := repo.GetUnit(models.UnitTypePullRequests); err == nil {
config := unit.PullRequestsConfig()
hasPullRequests = true
@@ -79,6 +80,7 @@ func innerToRepo(repo *models.Repository, mode models.AccessMode, isParent bool)
allowRebase = config.AllowRebase
allowRebaseMerge = config.AllowRebaseMerge
allowSquash = config.AllowSquash
defaultMergeStyle = config.GetDefaultMergeStyle()
}
hasProjects := false
if _, err := repo.GetUnit(models.UnitTypeProjects); err == nil {
@@ -139,6 +141,7 @@ func innerToRepo(repo *models.Repository, mode models.AccessMode, isParent bool)
AllowRebase: allowRebase,
AllowRebaseMerge: allowRebaseMerge,
AllowSquash: allowSquash,
DefaultMergeStyle: string(defaultMergeStyle),
AvatarURL: repo.AvatarLink(),
Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
MirrorInterval: mirrorInterval,

View File

@@ -140,6 +140,7 @@ type RepoSettingForm struct {
PullsAllowRebaseMerge bool
PullsAllowSquash bool
PullsAllowManualMerge bool
PullsDefaultMergeStyle string
EnableAutodetectManualMerge bool
EnableTimetracker bool
AllowOnlyContributorsToTrackTime bool

View File

@@ -89,6 +89,7 @@ type Repository struct {
AllowRebase bool `json:"allow_rebase"`
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
AllowSquash bool `json:"allow_squash_merge"`
DefaultMergeStyle string `json:"default_merge_style"`
AvatarURL string `json:"avatar_url"`
Internal bool `json:"internal"`
MirrorInterval string `json:"mirror_interval"`
@@ -171,6 +172,8 @@ type EditRepoOption struct {
AllowManualMerge *bool `json:"allow_manual_merge,omitempty"`
// either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur.
AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"`
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`.
DefaultMergeStyle *string `json:"default_merge_style,omitempty"`
// set to `true` to archive this repository.
Archived *bool `json:"archived,omitempty"`
// set to a string like `8h30m0s` to set the mirror interval time