feat(healthcheck): git lfs fsck --pointers
This commit is contained in:
parent
38d00246cf
commit
6643644865
|
@ -16,13 +16,20 @@ func All(
|
|||
metaFile []string, repoSize float64,
|
||||
) (res Result) {
|
||||
var err error
|
||||
err = RepoSize(repoSize)
|
||||
err = RepoSize(rootDir, repoSize)
|
||||
if err != nil {
|
||||
res.Msg += fmt.Sprintf("### Repo Size Check Failed:\n%s\n", err.Error())
|
||||
res.Failed = true
|
||||
} else {
|
||||
res.Msg += "### Repo Size Check Passed\n"
|
||||
}
|
||||
err = RepoLFS(rootDir)
|
||||
if err != nil {
|
||||
res.Msg += fmt.Sprintf("### Repo LFS Check Failed:\n%s\n", err.Error())
|
||||
res.Failed = true
|
||||
} else {
|
||||
res.Msg += "### Repo LFS Check Passed\n"
|
||||
}
|
||||
err = ForbiddenCheck(rootDir)
|
||||
if err != nil {
|
||||
res.Msg += fmt.Sprintf("### Forbidden File Check Failed:\n%s\n", err.Error())
|
||||
|
|
20
pkg/healthcheck/repolfs.go
Normal file
20
pkg/healthcheck/repolfs.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package healthcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func RepoLFS(workDir string) error {
|
||||
cmd := exec.Command("git", "lfs", "fsck", "--pointers")
|
||||
cmd.Dir = workDir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"error running `git lfs fsck --pointers`: %w, output: %s",
|
||||
err,
|
||||
output,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// RepoSize checks the size of the repository to determine if it is oversized.
|
||||
// It executes the 'git count-objects -v' command to obtain the size information,
|
||||
func RepoSize(confSize float64) error {
|
||||
func RepoSize(rootDir string, confSize float64) error {
|
||||
// TODO: reimplement here when go-git is available
|
||||
// https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md
|
||||
cmd := exec.Command(
|
||||
|
@ -20,6 +20,7 @@ func RepoSize(confSize float64) error {
|
|||
"count-objects",
|
||||
"-v",
|
||||
)
|
||||
cmd.Dir = rootDir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
slog.Error("running git command:", "err", err, "output", output)
|
||||
|
|
Loading…
Reference in New Issue
Block a user