From 8ca0125f23e2a0a0e74478bc95956b961ebaa73b Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 28 Jun 2025 09:50:17 -0400 Subject: [PATCH] feat(healthcheck): git lfs with safe.directory --- pkg/healthcheck/repolfs.go | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/pkg/healthcheck/repolfs.go b/pkg/healthcheck/repolfs.go index c325991..3f52508 100644 --- a/pkg/healthcheck/repolfs.go +++ b/pkg/healthcheck/repolfs.go @@ -1,15 +1,27 @@ package healthcheck +import ( + "fmt" + "os/exec" +) + func RepoLFS(rootDir string) error { - // cmd := exec.Command("git", "lfs", "fsck", "--pointers") - // cmd.Dir = rootDir - // output, err := cmd.CombinedOutput() - // if err != nil { - // return fmt.Errorf( - // "error running `git lfs fsck --pointers`: %w, output: %s", - // err, - // output, - // ) - // } + cmd := exec.Command( + "git", + "-c", + "safe.directory=*", + "lfs", + "fsck", + "--pointers", + ) + cmd.Dir = rootDir + output, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf( + "error running `git lfs fsck --pointers`: %w, output: %s", + err, + output, + ) + } return nil }