mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Move unit into models/unit/ (#17576)
* Move unit into models/unit/ * Rename unit.UnitType as unit.Type
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
@@ -93,12 +94,12 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
}
|
||||
|
||||
// The default unit we're trying to look at is code
|
||||
unitType := models.UnitTypeCode
|
||||
unitType := unit.TypeCode
|
||||
|
||||
// Unless we're a wiki...
|
||||
if strings.HasSuffix(repoName, ".wiki") {
|
||||
// in which case we need to look at the wiki
|
||||
unitType = models.UnitTypeWiki
|
||||
unitType = unit.TypeWiki
|
||||
// And we'd better munge the reponame and tell downstream we're looking at a wiki
|
||||
results.IsWiki = true
|
||||
results.RepoName = repoName[:len(repoName)-5]
|
||||
@@ -295,7 +296,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
}
|
||||
} else {
|
||||
// Because of the special ref "refs/for" we will need to delay write permission check
|
||||
if git.SupportProcReceive && unitType == models.UnitTypeCode {
|
||||
if git.SupportProcReceive && unitType == unit.TypeCode {
|
||||
mode = models.AccessModeRead
|
||||
}
|
||||
|
||||
@@ -362,7 +363,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
|
||||
if results.IsWiki {
|
||||
// Ensure the wiki is enabled before we allow access to it
|
||||
if _, err := repo.GetUnit(models.UnitTypeWiki); err != nil {
|
||||
if _, err := repo.GetUnit(unit.TypeWiki); err != nil {
|
||||
if models.IsErrUnitTypeNotExist(err) {
|
||||
ctx.JSON(http.StatusForbidden, private.ErrServCommand{
|
||||
Results: results,
|
||||
|
Reference in New Issue
Block a user