Make manual merge autodetection optional and add manual merge as merge method (#12543)
* Make auto check manual merge as a chooseable mod and add manual merge way on ui as title, Before this pr, we use same way with GH to check manually merge. It good, but in some special cases, misjudgments can occur. and it's hard to fix this bug. So I add option to allow repo manager block "auto check manual merge" function, Then it will have same style like gitlab(allow empty pr). and to compensate for not being able to detect THE PR merge automatically, I added a manual approach. Signed-off-by: a1012112796 <1012112796@qq.com> * make swager * api support * ping ci * fix TestPullCreate_EmptyChangesWithCommits * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * Apply review suggestions and add test * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * fix build * test error message * make fmt * Fix indentation issues identified by @silverwind Co-authored-by: silverwind <me@silverwind.io> * Fix tests and make manually merged disabled error on API the same Signed-off-by: Andrew Thornton <art27@cantab.net> * a small nit * fix wrong commit id error * fix bug * simple test * fix test Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
523efa433b
commit
a5279b74b6
25 changed files with 379 additions and 23 deletions
|
@ -35,6 +35,7 @@ const (
|
|||
PullRequestStatusMergeable
|
||||
PullRequestStatusManuallyMerged
|
||||
PullRequestStatusError
|
||||
PullRequestStatusEmpty
|
||||
)
|
||||
|
||||
// PullRequest represents relation between pull request and repositories.
|
||||
|
@ -332,6 +333,11 @@ func (pr *PullRequest) CanAutoMerge() bool {
|
|||
return pr.Status == PullRequestStatusMergeable
|
||||
}
|
||||
|
||||
// IsEmpty returns true if this pull request is empty.
|
||||
func (pr *PullRequest) IsEmpty() bool {
|
||||
return pr.Status == PullRequestStatusEmpty
|
||||
}
|
||||
|
||||
// MergeStyle represents the approach to merge commits into base branch.
|
||||
type MergeStyle string
|
||||
|
||||
|
@ -344,6 +350,8 @@ const (
|
|||
MergeStyleRebaseMerge MergeStyle = "rebase-merge"
|
||||
// MergeStyleSquash squash commits into single commit before merging
|
||||
MergeStyleSquash MergeStyle = "squash"
|
||||
// MergeStyleManuallyMerged pr has been merged manually, just mark it as merged directly
|
||||
MergeStyleManuallyMerged MergeStyle = "manually-merged"
|
||||
)
|
||||
|
||||
// SetMerged sets a pull request to merged and closes the corresponding issue
|
||||
|
|
|
@ -101,6 +101,8 @@ type PullRequestsConfig struct {
|
|||
AllowRebase bool
|
||||
AllowRebaseMerge bool
|
||||
AllowSquash bool
|
||||
AllowManualMerge bool
|
||||
AutodetectManualMerge bool
|
||||
}
|
||||
|
||||
// FromDB fills up a PullRequestsConfig from serialized format.
|
||||
|
@ -120,7 +122,8 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool {
|
|||
return mergeStyle == MergeStyleMerge && cfg.AllowMerge ||
|
||||
mergeStyle == MergeStyleRebase && cfg.AllowRebase ||
|
||||
mergeStyle == MergeStyleRebaseMerge && cfg.AllowRebaseMerge ||
|
||||
mergeStyle == MergeStyleSquash && cfg.AllowSquash
|
||||
mergeStyle == MergeStyleSquash && cfg.AllowSquash ||
|
||||
mergeStyle == MergeStyleManuallyMerged && cfg.AllowManualMerge
|
||||
}
|
||||
|
||||
// AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue