|
|
|
@@ -222,9 +222,10 @@ type Repository struct { |
|
|
|
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` |
|
|
|
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` |
|
|
|
|
|
|
|
Hot int64 `xorm:"-"` |
|
|
|
Active int64 `xorm:"-"` |
|
|
|
Alias string |
|
|
|
Hot int64 `xorm:"-"` |
|
|
|
Active int64 `xorm:"-"` |
|
|
|
Alias string `xorm:"INDEX"` |
|
|
|
LowerAlias string `xorm:"INDEX"` |
|
|
|
} |
|
|
|
|
|
|
|
// SanitizedOriginalURL returns a sanitized OriginalURL |
|
|
|
@@ -942,10 +943,10 @@ func isRepositoryExist(e Engine, u *User, repoName string, alias string) (bool, |
|
|
|
cond = cond.And(builder.Eq{"owner_id": u.ID}) |
|
|
|
if alias != "" { |
|
|
|
subCon := builder.NewCond() |
|
|
|
subCon = subCon.Or(builder.Eq{"alias": alias}, builder.Eq{"lower_name": repoName}) |
|
|
|
subCon = subCon.Or(builder.Eq{"lower_alias": strings.ToLower(alias)}, builder.Eq{"lower_name": strings.ToLower(repoName)}) |
|
|
|
cond = cond.And(subCon) |
|
|
|
} else { |
|
|
|
cond = cond.And(builder.Eq{"lower_name": repoName}) |
|
|
|
cond = cond.And(builder.Eq{"lower_name": strings.ToLower(repoName)}) |
|
|
|
} |
|
|
|
count, err := e.Where(cond).Count(&Repository{}) |
|
|
|
return count > 0 || com.IsDir(RepoPath(u.Name, repoName)), err |
|
|
|
@@ -964,7 +965,7 @@ func IsRepositoryAliasExist(u *User, alias string) (bool, error) { |
|
|
|
func isRepositoryAliasExist(e Engine, u *User, alias string) (bool, error) { |
|
|
|
var cond = builder.NewCond() |
|
|
|
cond = cond.And(builder.Eq{"owner_id": u.ID}) |
|
|
|
cond = cond.And(builder.Eq{"alias": alias}) |
|
|
|
cond = cond.And(builder.Eq{"lower_alias": strings.ToLower(alias)}) |
|
|
|
count, err := e.Where(cond).Count(&Repository{}) |
|
|
|
return count > 0, err |
|
|
|
} |
|
|
|
@@ -1108,6 +1109,7 @@ func IsUsableRepoAlias(name string) error { |
|
|
|
|
|
|
|
// CreateRepository creates a repository for the user/organization. |
|
|
|
func CreateRepository(ctx DBContext, doer, u *User, repo *Repository) (err error) { |
|
|
|
repo.LowerAlias = strings.ToLower(repo.Alias) |
|
|
|
if err = IsUsableRepoName(repo.Name); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|