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:
wxiaoguang
2026-07-24 01:42:55 +08:00
committed by GitHub
parent 86a3048247
commit 7065637e61
22 changed files with 216 additions and 186 deletions
-7
View File
@@ -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)