diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-09 00:46:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 18:46:32 +0200 |
commit | 4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65 (patch) | |
tree | fee132403adea441987ce25809c764e00fd962cd /routers/web | |
parent | d4834071da9ce010fd4677ef339c598dd23dc130 (diff) | |
download | gitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.tar.gz gitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.zip |
Move some helper files out of models (#19355)
* Move some helper files out of models
* Some improvements
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/branch.go | 2 | ||||
-rw-r--r-- | routers/web/repo/http.go | 19 | ||||
-rw-r--r-- | routers/web/repo/lfs.go | 5 |
3 files changed, 14 insertions, 12 deletions
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 732b9c9d54..08f388bf3c 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -129,7 +129,7 @@ func RestoreBranchPost(ctx *context.Context) { if err := git.Push(ctx, ctx.Repo.Repository.RepoPath(), git.PushOptions{ Remote: ctx.Repo.Repository.RepoPath(), Branch: fmt.Sprintf("%s:%s%s", deletedBranch.Commit, git.BranchPrefix, deletedBranch.Name), - Env: models.PushingEnvironment(ctx.Doer, ctx.Repo.Repository), + Env: repo_module.PushingEnvironment(ctx.Doer, ctx.Repo.Repository), }); err != nil { if strings.Contains(err.Error(), "already exists") { log.Debug("RestoreBranch: Can't restore branch '%s', since one with same name already exist", deletedBranch.Name) diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go index cc44c8e7e4..a52d9b76c2 100644 --- a/routers/web/repo/http.go +++ b/routers/web/repo/http.go @@ -27,6 +27,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" @@ -204,21 +205,21 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { } environ = []string{ - models.EnvRepoUsername + "=" + username, - models.EnvRepoName + "=" + reponame, - models.EnvPusherName + "=" + ctx.Doer.Name, - models.EnvPusherID + fmt.Sprintf("=%d", ctx.Doer.ID), - models.EnvAppURL + "=" + setting.AppURL, + repo_module.EnvRepoUsername + "=" + username, + repo_module.EnvRepoName + "=" + reponame, + repo_module.EnvPusherName + "=" + ctx.Doer.Name, + repo_module.EnvPusherID + fmt.Sprintf("=%d", ctx.Doer.ID), + repo_module.EnvAppURL + "=" + setting.AppURL, } if !ctx.Doer.KeepEmailPrivate { - environ = append(environ, models.EnvPusherEmail+"="+ctx.Doer.Email) + environ = append(environ, repo_module.EnvPusherEmail+"="+ctx.Doer.Email) } if isWiki { - environ = append(environ, models.EnvRepoIsWiki+"=true") + environ = append(environ, repo_module.EnvRepoIsWiki+"=true") } else { - environ = append(environ, models.EnvRepoIsWiki+"=false") + environ = append(environ, repo_module.EnvRepoIsWiki+"=false") } } @@ -269,7 +270,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { } } - environ = append(environ, models.EnvRepoID+fmt.Sprintf("=%d", repo.ID)) + environ = append(environ, repo_module.EnvRepoID+fmt.Sprintf("=%d", repo.ID)) w := ctx.Resp r := ctx.Req diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go index e0ef864edf..7c2ff1cfae 100644 --- a/routers/web/repo/lfs.go +++ b/routers/web/repo/lfs.go @@ -23,6 +23,7 @@ import ( "code.gitea.io/gitea/modules/git/pipeline" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" + repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/typesniffer" @@ -103,14 +104,14 @@ func LFSLocks(ctx *context.Context) { } // Clone base repo. - tmpBasePath, err := models.CreateTemporaryPath("locks") + tmpBasePath, err := repo_module.CreateTemporaryPath("locks") if err != nil { log.Error("Failed to create temporary path: %v", err) ctx.ServerError("LFSLocks", err) return } defer func() { - if err := models.RemoveTemporaryPath(tmpBasePath); err != nil { + if err := repo_module.RemoveTemporaryPath(tmpBasePath); err != nil { log.Error("LFSLocks: RemoveTemporaryPath: %v", err) } }() |