mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 12:09:37 +00:00
refactor: hide git repo path details from more packages (#38601)
Remove `RepoPath` from "models/repo" package, remove `UserPath` from "models/user" package, use `WithRepo` for more places, fine tune tests.
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"maps"
|
||||
"net"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -564,16 +563,6 @@ func (repo *Repository) IsGenerated() bool {
|
||||
return repo.TemplateID != 0
|
||||
}
|
||||
|
||||
// RepoPath returns repository path by given user and repository name.
|
||||
func RepoPath(userName, repoName string) string { //revive:disable-line:exported
|
||||
return filepath.Join(setting.RepoRootPath, filepath.Clean(strings.ToLower(userName)), filepath.Clean(strings.ToLower(repoName)+".git"))
|
||||
}
|
||||
|
||||
// RepoPath returns the repository path
|
||||
func (repo *Repository) RepoPath() string {
|
||||
return RepoPath(repo.OwnerName, repo.Name)
|
||||
}
|
||||
|
||||
// Link returns the repository relative url
|
||||
func (repo *Repository) Link() string {
|
||||
return setting.AppSubURL + "/" + url.PathEscape(repo.OwnerName) + "/" + url.PathEscape(repo.Name)
|
||||
|
||||
@@ -15,8 +15,8 @@ func repoCodeGitRepoManagedID(repoID int64) string {
|
||||
|
||||
func (repo *Repository) CodeStorageRepo() gitrepo.RepositoryFacade {
|
||||
id := repoCodeGitRepoManagedID(repo.ID)
|
||||
repoPath := gitrepo.RepoCodeGitRepoRelativePath(repo.OwnerName, repo.Name)
|
||||
return gitrepo.RepositoryManaged(id, repoPath)
|
||||
relPath := gitrepo.RepoCodeGitRepoRelativePath(repo.OwnerName, repo.Name)
|
||||
return gitrepo.RepositoryManaged(id, relPath)
|
||||
}
|
||||
|
||||
func (repo *Repository) GitRepoLocation() string {
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"mime"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -993,12 +992,6 @@ func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, er
|
||||
Find(&users)
|
||||
}
|
||||
|
||||
// UserPath returns the path absolute path of user repositories.
|
||||
// FIXME: it should be in "git/gitrepo" package
|
||||
func UserPath(userName string) string { //revive:disable-line:exported
|
||||
return filepath.Join(setting.RepoRootPath, filepath.Clean(strings.ToLower(userName)))
|
||||
}
|
||||
|
||||
// GetUserByID returns the user object by given ID if exists.
|
||||
func GetUserByID(ctx context.Context, id int64) (*User, error) {
|
||||
u := new(User)
|
||||
|
||||
Reference in New Issue
Block a user