diff options
author | George Bartolomey <george@bh4.ru> | 2024-12-14 08:12:04 +0100 |
---|---|---|
committer | George Bartolomey <george@bh4.ru> | 2024-12-23 16:55:25 +0100 |
commit | 13ca6c14f16cf2f76243f5fd1bb7efb763de8a36 (patch) | |
tree | 689974045bd95e3d3ea4c6e432072bea806c89e9 /modules | |
parent | Merge pull request 'Update module google.golang.org/grpc to v1.69.2 (forgejo)... (diff) | |
download | forgejo-13ca6c14f16cf2f76243f5fd1bb7efb763de8a36.tar.xz forgejo-13ca6c14f16cf2f76243f5fd1bb7efb763de8a36.zip |
feat: allow changing default branch update style
This commit allows chaning default branch update style through global
and repository settings. The setting affects "Update branch" button
in PR view (button shows when some commits are ahead of master branch).
When default update style is set to "rebase", dropdown button updates branch
by rebase by default. When update style is set to other value, dropdown button
updates branch by merge. Any of these actions may be selected using dropdown
in any case.
Signed-off-by: George Bartolomey <george@bh4.ru>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/repository/create.go | 5 | ||||
-rw-r--r-- | modules/setting/repository.go | 3 | ||||
-rw-r--r-- | modules/structs/repo.go | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/modules/repository/create.go b/modules/repository/create.go index ca2150b972..32c6235544 100644 --- a/modules/repository/create.go +++ b/modules/repository/create.go @@ -89,8 +89,9 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re Type: tp, Config: &repo_model.PullRequestsConfig{ AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, AllowFastForwardOnly: true, - DefaultMergeStyle: repo_model.MergeStyle(setting.Repository.PullRequest.DefaultMergeStyle), - AllowRebaseUpdate: true, + DefaultMergeStyle: repo_model.MergeStyle(setting.Repository.PullRequest.DefaultMergeStyle), + DefaultUpdateStyle: repo_model.UpdateStyle(setting.Repository.PullRequest.DefaultUpdateStyle), + AllowRebaseUpdate: true, }, }) } else { diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 6086dd1d57..d13f25f554 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -87,6 +87,7 @@ var ( DefaultMergeMessageAllAuthors bool DefaultMergeMessageMaxApprovers int DefaultMergeMessageOfficialApproversOnly bool + DefaultUpdateStyle string PopulateSquashCommentWithCommitMessages bool AddCoCommitterTrailers bool TestConflictingPatchesWithGitApply bool @@ -216,6 +217,7 @@ var ( DefaultMergeMessageAllAuthors bool DefaultMergeMessageMaxApprovers int DefaultMergeMessageOfficialApproversOnly bool + DefaultUpdateStyle string PopulateSquashCommentWithCommitMessages bool AddCoCommitterTrailers bool TestConflictingPatchesWithGitApply bool @@ -232,6 +234,7 @@ var ( DefaultMergeMessageAllAuthors: false, DefaultMergeMessageMaxApprovers: 10, DefaultMergeMessageOfficialApproversOnly: true, + DefaultUpdateStyle: "merge", PopulateSquashCommentWithCommitMessages: false, AddCoCommitterTrailers: true, RetargetChildrenOnMerge: true, diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 36190fe36b..b5f54a2a7a 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -105,6 +105,7 @@ type Repository struct { DefaultDeleteBranchAfterMerge bool `json:"default_delete_branch_after_merge"` DefaultMergeStyle string `json:"default_merge_style"` DefaultAllowMaintainerEdit bool `json:"default_allow_maintainer_edit"` + DefaultUpdateStyle string `json:"default_update_style"` AvatarURL string `json:"avatar_url"` Internal bool `json:"internal"` MirrorInterval string `json:"mirror_interval"` @@ -225,6 +226,8 @@ type EditRepoOption struct { DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"` // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only". DefaultMergeStyle *string `json:"default_merge_style,omitempty"` + // set to a update style to be used by this repository: "rebase" or "merge" + DefaultUpdateStyle *string `json:"default_update_style,omitempty"` // set to `true` to allow edits from maintainers by default DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"` // set to `true` to archive this repository. |