summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-03-27 00:26:34 +0200
committerGitHub <noreply@github.com>2020-03-27 00:26:34 +0200
commitbbd910ed1b4f52ee66a5cdd8d11f856598161bef (patch)
tree8392e0f8208b5b7d8e6df8335677518aa07f194f /models/error.go
parent52cfd2743c0e85b36081cf80a850e6a5901f1865 (diff)
downloadgitea-bbd910ed1b4f52ee66a5cdd8d11f856598161bef.tar.gz
gitea-bbd910ed1b4f52ee66a5cdd8d11f856598161bef.zip
Allow to set protected file patterns that can not be changed under no conditions (#10806)
Co-Authored-By: zeripath <art27@cantab.net>
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index 09fb4ebcaf..19a1229ada 100644
--- a/models/error.go
+++ b/models/error.go
@@ -916,6 +916,25 @@ func (err ErrFilePathInvalid) Error() string {
return fmt.Sprintf("path is invalid [path: %s]", err.Path)
}
+// ErrFilePathProtected represents a "FilePathProtected" kind of error.
+type ErrFilePathProtected struct {
+ Message string
+ Path string
+}
+
+// IsErrFilePathProtected checks if an error is an ErrFilePathProtected.
+func IsErrFilePathProtected(err error) bool {
+ _, ok := err.(ErrFilePathProtected)
+ return ok
+}
+
+func (err ErrFilePathProtected) Error() string {
+ if err.Message != "" {
+ return err.Message
+ }
+ return fmt.Sprintf("path is protected and can not be changed [path: %s]", err.Path)
+}
+
// ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo.
type ErrUserDoesNotHaveAccessToRepo struct {
UserID int64