mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	#1511 Allow local import only for admin users
This commit is contained in:
		@@ -18,7 +18,7 @@ func IsErrNameReserved(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrNameReserved) Error() string {
 | 
			
		||||
	return fmt.Sprintf("name is reserved: [name: %s]", err.Name)
 | 
			
		||||
	return fmt.Sprintf("name is reserved [name: %s]", err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrNamePatternNotAllowed struct {
 | 
			
		||||
@@ -31,7 +31,7 @@ func IsErrNamePatternNotAllowed(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrNamePatternNotAllowed) Error() string {
 | 
			
		||||
	return fmt.Sprintf("name pattern is not allowed: [pattern: %s]", err.Pattern)
 | 
			
		||||
	return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//  ____ ___
 | 
			
		||||
@@ -51,7 +51,7 @@ func IsErrUserAlreadyExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrUserAlreadyExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("user already exists: [name: %s]", err.Name)
 | 
			
		||||
	return fmt.Sprintf("user already exists [name: %s]", err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrUserNotExist struct {
 | 
			
		||||
@@ -65,7 +65,7 @@ func IsErrUserNotExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrUserNotExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("user does not exist: [uid: %d, name: %s]", err.UID, err.Name)
 | 
			
		||||
	return fmt.Sprintf("user does not exist [uid: %d, name: %s]", err.UID, err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrEmailAlreadyUsed struct {
 | 
			
		||||
@@ -78,7 +78,7 @@ func IsErrEmailAlreadyUsed(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrEmailAlreadyUsed) Error() string {
 | 
			
		||||
	return fmt.Sprintf("e-mail has been used: [email: %s]", err.Email)
 | 
			
		||||
	return fmt.Sprintf("e-mail has been used [email: %s]", err.Email)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrUserOwnRepos struct {
 | 
			
		||||
@@ -91,7 +91,7 @@ func IsErrUserOwnRepos(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrUserOwnRepos) Error() string {
 | 
			
		||||
	return fmt.Sprintf("user still has ownership of repositories: [uid: %d]", err.UID)
 | 
			
		||||
	return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrUserHasOrgs struct {
 | 
			
		||||
@@ -104,7 +104,7 @@ func IsErrUserHasOrgs(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrUserHasOrgs) Error() string {
 | 
			
		||||
	return fmt.Sprintf("user still has membership of organizations: [uid: %d]", err.UID)
 | 
			
		||||
	return fmt.Sprintf("user still has membership of organizations [uid: %d]", err.UID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// __________     ___.   .__  .__          ____  __.
 | 
			
		||||
@@ -124,7 +124,7 @@ func IsErrKeyNotExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrKeyNotExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("public key does not exist: [id: %d]", err.ID)
 | 
			
		||||
	return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrKeyAlreadyExist struct {
 | 
			
		||||
@@ -138,7 +138,7 @@ func IsErrKeyAlreadyExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrKeyAlreadyExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("public key already exists: [owner_id: %d, content: %s]", err.OwnerID, err.Content)
 | 
			
		||||
	return fmt.Sprintf("public key already exists [owner_id: %d, content: %s]", err.OwnerID, err.Content)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrKeyNameAlreadyUsed struct {
 | 
			
		||||
@@ -152,7 +152,7 @@ func IsErrKeyNameAlreadyUsed(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrKeyNameAlreadyUsed) Error() string {
 | 
			
		||||
	return fmt.Sprintf("public key already exists: [owner_id: %d, name: %s]", err.OwnerID, err.Name)
 | 
			
		||||
	return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrDeployKeyAlreadyExist struct {
 | 
			
		||||
@@ -166,7 +166,7 @@ func IsErrDeployKeyAlreadyExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrDeployKeyAlreadyExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("public key already exists: [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
 | 
			
		||||
	return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrDeployKeyNameAlreadyUsed struct {
 | 
			
		||||
@@ -180,7 +180,7 @@ func IsErrDeployKeyNameAlreadyUsed(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrDeployKeyNameAlreadyUsed) Error() string {
 | 
			
		||||
	return fmt.Sprintf("public key already exists: [repo_id: %d, name: %s]", err.RepoID, err.Name)
 | 
			
		||||
	return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//    _____                                   ___________     __
 | 
			
		||||
@@ -200,7 +200,7 @@ func IsErrAccessTokenNotExist(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrAccessTokenNotExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("access token does not exist: [sha: %s]", err.SHA)
 | 
			
		||||
	return fmt.Sprintf("access token does not exist [sha: %s]", err.SHA)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ________                            .__                __  .__
 | 
			
		||||
@@ -220,7 +220,7 @@ func IsErrLastOrgOwner(err error) bool {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrLastOrgOwner) Error() string {
 | 
			
		||||
	return fmt.Sprintf("user is the last member of owner team: [uid: %d]", err.UID)
 | 
			
		||||
	return fmt.Sprintf("user is the last member of owner team [uid: %d]", err.UID)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// __________                           .__  __
 | 
			
		||||
@@ -259,6 +259,22 @@ func (err ErrRepoAlreadyExist) Error() string {
 | 
			
		||||
	return fmt.Sprintf("repository already exists [uname: %s, name: %s]", err.Uname, err.Name)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ErrInvalidCloneAddr struct {
 | 
			
		||||
	IsURLError         bool
 | 
			
		||||
	IsInvalidPath      bool
 | 
			
		||||
	IsPermissionDenied bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func IsErrInvalidCloneAddr(err error) bool {
 | 
			
		||||
	_, ok := err.(ErrInvalidCloneAddr)
 | 
			
		||||
	return ok
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (err ErrInvalidCloneAddr) Error() string {
 | 
			
		||||
	return fmt.Sprintf("invalid clone address [is_url_error: %v, is_invalid_path: %v, is_permission_denied: %v]",
 | 
			
		||||
		err.IsURLError, err.IsInvalidPath, err.IsPermissionDenied)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//  __      __      ___.   .__                   __
 | 
			
		||||
// /  \    /  \ ____\_ |__ |  |__   ____   ____ |  | __
 | 
			
		||||
// \   \/\/   // __ \| __ \|  |  \ /  _ \ /  _ \|  |/ /
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user