feat/reposize #56

Merged
张泊明518370910136 merged 8 commits from feat/reposize into master 2024-10-12 18:30:55 +08:00
2 changed files with 5 additions and 4 deletions

View File

@ -44,6 +44,7 @@ func main() {
checkRelease := flag.Bool("checkRelease", true, "trigger release check") checkRelease := flag.Bool("checkRelease", true, "trigger release check")
rootDir := flag.String("root", "", "") rootDir := flag.String("root", "", "")
repo := flag.String("repo", "", "") repo := flag.String("repo", "", "")
size := flag.Float64("reposize", 2, "size of the repo")
localList := flag.String("localList", "", "") localList := flag.String("localList", "", "")
droneBranch := flag.String("droneBranch", "", "") droneBranch := flag.String("droneBranch", "", "")
checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.") checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.")
@ -57,7 +58,7 @@ func main() {
} }
setupSlog() setupSlog()
var err error var err error
err = healthcheck.RepoSize() err = healthcheck.RepoSize(*size)
if err != nil { if err != nil {
fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error()) fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error())
} }

View File

@ -10,7 +10,7 @@ import (
// RepoSize checks the size of the repository to determine if it is oversized. // 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, // It executes the 'git count-objects -v' command to obtain the size information,
func RepoSize() error { func RepoSize(confSize float64) error {
// TODO: reimplement here when go-git is available // TODO: reimplement here when go-git is available
// https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md // https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md
cmd := exec.Command("git", "count-objects", "-v") cmd := exec.Command("git", "count-objects", "-v")
@ -33,8 +33,8 @@ func RepoSize() error {
sum += size sum += size
} }
} }
if sum > 2048 { if sum > int(confSize*1024) {
return fmt.Errorf("Repository larger than 2MB. Please clean up or contact the teaching team.") return fmt.Errorf("Repository larger than %.1f MiB. Please clean up or contact the teaching team.", confSize)
} }
return nil return nil
} }