1
0
Fork 0
forked from forgejo/forgejo

Finish close and reopen issue, install page, ready going to test stage of v0.2.0

This commit is contained in:
Unknown 2014-03-29 17:50:51 -04:00
parent 1f671e5d29
commit 107a1eadac
15 changed files with 315 additions and 161 deletions

View file

@ -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
}
}