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:
wxiaoguang
2026-07-21 02:03:28 +08:00
committed by GitHub
parent 9dc04289aa
commit a4526d5a82
28 changed files with 146 additions and 107 deletions
+4 -4
View File
@@ -38,7 +38,7 @@ func ListGitHooks(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
hooks, err := ctx.Repo.GitRepo.Hooks()
hooks, err := git.ListHooks(ctx.Repo.GitRepo)
if err != nil {
ctx.APIErrorInternal(err)
return
@@ -81,7 +81,7 @@ func GetGitHook(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
if err != nil {
if errors.Is(err, git.ErrNotValidHook) {
ctx.APIErrorNotFound()
@@ -128,7 +128,7 @@ func EditGitHook(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditGitHookOption)
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
if err != nil {
if errors.Is(err, git.ErrNotValidHook) {
ctx.APIErrorNotFound()
@@ -177,7 +177,7 @@ func DeleteGitHook(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
hookID := ctx.PathParam("id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
if err != nil {
if errors.Is(err, git.ErrNotValidHook) {
ctx.APIErrorNotFound()