aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2018-03-08 07:15:55 -0500
committerUnknwon <u@gogs.io>2018-03-08 07:15:55 -0500
commit1f7983059aa80307a86c19088decaedfeb019755 (patch)
treef47209b37efbd5cbb585e2ea66f24fa5af14a06a /models
parent51e087fd8731137c969f616bc90f383a2c2bff27 (diff)
models: move ErrBranchNotExist to errors package
Diffstat (limited to 'models')
-rw-r--r--models/error.go20
-rw-r--r--models/errors/repo.go13
-rw-r--r--models/repo_branch.go5
3 files changed, 16 insertions, 22 deletions
diff --git a/models/error.go b/models/error.go
index 08548c7d..410a5a7e 100644
--- a/models/error.go
+++ b/models/error.go
@@ -388,26 +388,6 @@ func (err ErrRepoFileAlreadyExist) Error() string {
return fmt.Sprintf("repository file already exists [file_name: %s]", err.FileName)
}
-// __________ .__
-// \______ \____________ ____ ____ | |__
-// | | _/\_ __ \__ \ / \_/ ___\| | \
-// | | \ | | \// __ \| | \ \___| Y \
-// |______ / |__| (____ /___| /\___ >___| /
-// \/ \/ \/ \/ \/
-
-type ErrBranchNotExist struct {
- Name string
-}
-
-func IsErrBranchNotExist(err error) bool {
- _, ok := err.(ErrBranchNotExist)
- return ok
-}
-
-func (err ErrBranchNotExist) Error() string {
- return fmt.Sprintf("branch does not exist [name: %s]", err.Name)
-}
-
// __________ .__ .__ __________ __
// \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_
// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
diff --git a/models/errors/repo.go b/models/errors/repo.go
index 69c29be6..c9894af9 100644
--- a/models/errors/repo.go
+++ b/models/errors/repo.go
@@ -72,3 +72,16 @@ func IsBranchAlreadyExists(err error) bool {
func (err BranchAlreadyExists) Error() string {
return fmt.Sprintf("branch already exists [name: %s]", err.Name)
}
+
+type ErrBranchNotExist struct {
+ Name string
+}
+
+func IsErrBranchNotExist(err error) bool {
+ _, ok := err.(ErrBranchNotExist)
+ return ok
+}
+
+func (err ErrBranchNotExist) Error() string {
+ return fmt.Sprintf("branch does not exist [name: %s]", err.Name)
+}
diff --git a/models/repo_branch.go b/models/repo_branch.go
index 10931b0c..ce06c9f3 100644
--- a/models/repo_branch.go
+++ b/models/repo_branch.go
@@ -11,6 +11,7 @@ import (
"github.com/Unknwon/com"
"github.com/gogits/git-module"
+ "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/pkg/tool"
)
@@ -45,7 +46,7 @@ func GetBranchesByPath(path string) ([]*Branch, error) {
func (repo *Repository) GetBranch(br string) (*Branch, error) {
if !git.IsBranchExist(repo.RepoPath(), br) {
- return nil, ErrBranchNotExist{br}
+ return nil, errors.ErrBranchNotExist{br}
}
return &Branch{
RepoPath: repo.RepoPath(),
@@ -101,7 +102,7 @@ func GetProtectBranchOfRepoByName(repoID int64, name string) (*ProtectBranch, er
if err != nil {
return nil, err
} else if !has {
- return nil, ErrBranchNotExist{name}
+ return nil, errors.ErrBranchNotExist{name}
}
return protectBranch, nil
}