* Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
Showing the changes to models/error.go (1 of 67 files). Show all
Unified · Split
| @@ -8,7 +8,6 @@ package models · 7 unmodified lines | ||
| 8 | 8 | import ( |
| 9 | 9 | "fmt" |
| 10 | 10 | |
| 11 | − "code.gitea.io/gitea/models/perm" | |
| 12 | 11 | repo_model "code.gitea.io/gitea/models/repo" |
| 13 | 12 | "code.gitea.io/gitea/modules/git" |
| 14 | 13 | ) |
| @@ -145,83 +144,6 @@ func (err ErrAccessTokenEmpty) Error() string { · 130 unmodified lines | ||
| 145 | 144 | return "access token is empty" |
| 146 | 145 | } |
| 147 | 146 | |
| 148 | −//.____ ____________________ | |
| 149 | −//| | \_ _____/ _____/ | |
| 150 | −//| | | __) \_____ \ | |
| 151 | −//| |___| \ / \ | |
| 152 | −//|_______ \___ / /_______ / | |
| 153 | −// \/ \/ \/ | |
| 154 | − | |
| 155 | −// ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error. | |
| 156 | −type ErrLFSLockNotExist struct { | |
| 157 | − ID int64 | |
| 158 | − RepoID int64 | |
| 159 | − Path string | |
| 160 | −} | |
| 161 | − | |
| 162 | −// IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist. | |
| 163 | −func IsErrLFSLockNotExist(err error) bool { | |
| 164 | − _, ok := err.(ErrLFSLockNotExist) | |
| 165 | − return ok | |
| 166 | −} | |
| 167 | − | |
| 168 | −func (err ErrLFSLockNotExist) Error() string { | |
| 169 | − return fmt.Sprintf("lfs lock does not exist [id: %d, rid: %d, path: %s]", err.ID, err.RepoID, err.Path) | |
| 170 | −} | |
| 171 | − | |
| 172 | −// ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error. | |
| 173 | −type ErrLFSUnauthorizedAction struct { | |
| 174 | − RepoID int64 | |
| 175 | − UserName string | |
| 176 | − Mode perm.AccessMode | |
| 177 | −} | |
| 178 | − | |
| 179 | −// IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction. | |
| 180 | −func IsErrLFSUnauthorizedAction(err error) bool { | |
| 181 | − _, ok := err.(ErrLFSUnauthorizedAction) | |
| 182 | − return ok | |
| 183 | −} | |
| 184 | − | |
| 185 | −func (err ErrLFSUnauthorizedAction) Error() string { | |
| 186 | − if err.Mode == perm.AccessModeWrite { | |
| 187 | − return fmt.Sprintf("User %s doesn't have write access for lfs lock [rid: %d]", err.UserName, err.RepoID) | |
| 188 | − } | |
| 189 | − return fmt.Sprintf("User %s doesn't have read access for lfs lock [rid: %d]", err.UserName, err.RepoID) | |
| 190 | −} | |
| 191 | − | |
| 192 | −// ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error. | |
| 193 | −type ErrLFSLockAlreadyExist struct { | |
| 194 | − RepoID int64 | |
| 195 | − Path string | |
| 196 | −} | |
| 197 | − | |
| 198 | −// IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist. | |
| 199 | −func IsErrLFSLockAlreadyExist(err error) bool { | |
| 200 | − _, ok := err.(ErrLFSLockAlreadyExist) | |
| 201 | − return ok | |
| 202 | −} | |
| 203 | − | |
| 204 | −func (err ErrLFSLockAlreadyExist) Error() string { | |
| 205 | − return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path) | |
| 206 | −} | |
| 207 | − | |
| 208 | −// ErrLFSFileLocked represents a "LFSFileLocked" kind of error. | |
| 209 | −type ErrLFSFileLocked struct { | |
| 210 | − RepoID int64 | |
| 211 | − Path string | |
| 212 | − UserName string | |
| 213 | −} | |
| 214 | − | |
| 215 | −// IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked. | |
| 216 | −func IsErrLFSFileLocked(err error) bool { | |
| 217 | − _, ok := err.(ErrLFSFileLocked) | |
| 218 | − return ok | |
| 219 | −} | |
| 220 | − | |
| 221 | −func (err ErrLFSFileLocked) Error() string { | |
| 222 | − return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path) | |
| 223 | −} | |
| 224 | − | |
| 225 | 147 | // ErrNoPendingRepoTransfer is an error type for repositories without a pending |
| 226 | 148 | // transfer request |
| 227 | 149 | type ErrNoPendingRepoTransfer struct { |