mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 08:39:30 +00:00
refactor: remove Path field from git.Repository (#38552)
The "path" details should be hidden to other packages By the way, fix a resource leaking in gogit's CommitNodeIndex (the file was not closed in CacheCommit)
This commit is contained in:
+6
-4
@@ -11,6 +11,7 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"gitea.dev/modules/git/gitcmd"
|
||||
"gitea.dev/modules/util"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,8 @@ type Hook struct {
|
||||
}
|
||||
|
||||
// GetHook returns a Git hook by given name and repository.
|
||||
func GetHook(repoPath, name string) (*Hook, error) {
|
||||
func GetHook(repo RepositoryFacade, name string) (*Hook, error) {
|
||||
repoPath := gitcmd.RepoLocalPath(repo)
|
||||
if !IsValidHookName(name) {
|
||||
return nil, ErrNotValidHook
|
||||
}
|
||||
@@ -97,8 +99,8 @@ func (h *Hook) Update() error {
|
||||
}
|
||||
|
||||
// ListHooks returns a list of Git hooks of given repository.
|
||||
func ListHooks(repoPath string) (_ []*Hook, err error) {
|
||||
exist, err := util.IsDir(filepath.Join(repoPath, "hooks"))
|
||||
func ListHooks(repo RepositoryFacade) (_ []*Hook, err error) {
|
||||
exist, err := util.IsDir(filepath.Join(gitcmd.RepoLocalPath(repo), "hooks"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !exist {
|
||||
@@ -107,7 +109,7 @@ func ListHooks(repoPath string) (_ []*Hook, err error) {
|
||||
|
||||
hooks := make([]*Hook, len(hookNames))
|
||||
for i, name := range hookNames {
|
||||
hooks[i], err = GetHook(repoPath, name)
|
||||
hooks[i], err = GetHook(repo, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user