mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
Added checks for protected branches in pull requests (#3544)
* Added checks for protected branches in pull requests Signed-off-by: Christian Wulff <NChris@posteo.net> * Moved check for protected branch into new function CheckUserAllowedToMerge Signed-off-by: Christian Wulff <NChris@posteo.net> * Removed merge conflict lines from last commit Signed-off-by: Christian Wulff <NChris@posteo.net> * Explicit check for error type in ViewIssue Signed-off-by: Christian Wulff <NChris@posteo.net>
This commit is contained in:
@ -785,6 +785,21 @@ func (err ErrBranchNameConflict) Error() string {
|
||||
return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
|
||||
}
|
||||
|
||||
// ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it
|
||||
type ErrNotAllowedToMerge struct {
|
||||
Reason string
|
||||
}
|
||||
|
||||
// IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.
|
||||
func IsErrNotAllowedToMerge(err error) bool {
|
||||
_, ok := err.(ErrNotAllowedToMerge)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err ErrNotAllowedToMerge) Error() string {
|
||||
return fmt.Sprintf("not allowed to merge [reason: %s]", err.Reason)
|
||||
}
|
||||
|
||||
// ErrTagAlreadyExists represents an error that tag with such name already exists
|
||||
type ErrTagAlreadyExists struct {
|
||||
TagName string
|
||||
|
Reference in New Issue
Block a user