diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-29 17:50:51 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-29 17:50:51 -0400 |
commit | 107a1eadac72e610a9bcb68498751ca51ec8f51a (patch) | |
tree | 07830d247f89887882427c0bb910178bde4298ce /models/repo.go | |
parent | 1f671e5d2900497e2c81e8123cc47fe7ca5ad371 (diff) | |
download | gitea-107a1eadac72e610a9bcb68498751ca51ec8f51a.tar.gz gitea-107a1eadac72e610a9bcb68498751ca51ec8f51a.zip |
Finish close and reopen issue, install page, ready going to test stage of v0.2.0
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/models/repo.go b/models/repo.go index a848694da6..0b2bbe4862 100644 --- a/models/repo.go +++ b/models/repo.go @@ -11,7 +11,6 @@ import ( "os" "os/exec" "path/filepath" - "regexp" "strings" "time" "unicode/utf8" @@ -59,15 +58,6 @@ func NewRepoContext() { os.Exit(2) } } - - // Initialize illegal patterns. - for i := range illegalPatterns[1:] { - pattern := "" - for j := range illegalPatterns[i+1] { - pattern += "[" + string(illegalPatterns[i+1][j]-32) + string(illegalPatterns[i+1][j]) + "]" - } - illegalPatterns[i+1] = pattern - } } // Repository represents a git repository. @@ -105,15 +95,20 @@ func IsRepositoryExist(user *User, repoName string) (bool, error) { } var ( - // Define as all lower case!! - illegalPatterns = []string{"[.][Gg][Ii][Tt]", "raw", "user", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin"} + illegalEquals = []string{"raw", "install", "api", "avatar", "user", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin"} + illegalSuffixs = []string{".git"} ) // IsLegalName returns false if name contains illegal characters. func IsLegalName(repoName string) bool { - for _, pattern := range illegalPatterns { - has, _ := regexp.MatchString(pattern, repoName) - if has { + repoName = strings.ToLower(repoName) + for _, char := range illegalEquals { + if repoName == char { + return false + } + } + for _, char := range illegalSuffixs { + if strings.HasSuffix(repoName, char) { return false } } |