From 8fb707e07daaccf8604e5a4ea0a7df553c76bc99 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Fri, 11 Oct 2024 18:51:50 +0800 Subject: [PATCH 1/7] feat(healthcheck/reposize): customize repo size --- cmd/repo-health-checker/main.go | 3 ++- pkg/healthcheck/reposize.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/repo-health-checker/main.go b/cmd/repo-health-checker/main.go index 160b587..8a75261 100644 --- a/cmd/repo-health-checker/main.go +++ b/cmd/repo-health-checker/main.go @@ -44,6 +44,7 @@ func main() { checkRelease := flag.Bool("checkRelease", true, "trigger release check") rootDir := flag.String("root", "", "") repo := flag.String("repo", "", "") + size := flag.Int("reposize", 2, "size of the repo") localList := flag.String("localList", "", "") droneBranch := flag.String("droneBranch", "", "") checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.") @@ -57,7 +58,7 @@ func main() { } setupSlog() var err error - err = healthcheck.RepoSize() + err = healthcheck.RepoSize(*size) if err != nil { fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error()) } diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index dd17d06..4740a5a 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -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() error { +func RepoSize(conf_size int) error { // TODO: reimplement here when go-git is available // https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md cmd := exec.Command("git", "count-objects", "-v") @@ -33,8 +33,8 @@ func RepoSize() error { sum += size } } - if sum > 2048 { - return fmt.Errorf("Repository larger than 2MB. Please clean up or contact the teaching team.") + if sum > conf_size { + return fmt.Errorf("Repository larger than %d M. Please clean up or contact the teaching team.", conf_size) } return nil } -- 2.30.2 From 57c50c4f6838305c19cea5c0165bc59d660699e0 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Fri, 11 Oct 2024 19:02:23 +0800 Subject: [PATCH 2/7] fix(healthcheck/reposize): unit --- cmd/repo-health-checker/main.go | 2 +- pkg/healthcheck/reposize.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/repo-health-checker/main.go b/cmd/repo-health-checker/main.go index 8a75261..65b90dd 100644 --- a/cmd/repo-health-checker/main.go +++ b/cmd/repo-health-checker/main.go @@ -44,7 +44,7 @@ func main() { checkRelease := flag.Bool("checkRelease", true, "trigger release check") rootDir := flag.String("root", "", "") repo := flag.String("repo", "", "") - size := flag.Int("reposize", 2, "size of the repo") + size := flag.Float64("reposize", 2, "size of the repo") localList := flag.String("localList", "", "") droneBranch := flag.String("droneBranch", "", "") checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.") diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index 4740a5a..3d03a97 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -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(conf_size int) error { +func RepoSize(conf_size float64) error { // TODO: reimplement here when go-git is available // https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md cmd := exec.Command("git", "count-objects", "-v") @@ -33,7 +33,7 @@ func RepoSize(conf_size int) error { sum += size } } - if sum > conf_size { + if sum > int(conf_size*1024*1024) { return fmt.Errorf("Repository larger than %d M. Please clean up or contact the teaching team.", conf_size) } return nil -- 2.30.2 From c3ed1413a5b1369dbad8330c607bcfc89b8f3b94 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Fri, 11 Oct 2024 19:06:21 +0800 Subject: [PATCH 3/7] fix(healthcheck/reposize): unit --- pkg/healthcheck/reposize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index 3d03a97..b804b6e 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -34,7 +34,7 @@ func RepoSize(conf_size float64) error { } } if sum > int(conf_size*1024*1024) { - return fmt.Errorf("Repository larger than %d M. Please clean up or contact the teaching team.", conf_size) + return fmt.Errorf("Repository larger than %f M. Please clean up or contact the teaching team.", conf_size) } return nil } -- 2.30.2 From d38876e016ec63404eeecd78c396f6c16b7cf3c4 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Fri, 11 Oct 2024 19:30:15 +0800 Subject: [PATCH 4/7] fix(healthcheck/reposize): unit --- pkg/healthcheck/reposize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index b804b6e..ee61bba 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -33,7 +33,7 @@ func RepoSize(conf_size float64) error { sum += size } } - if sum > int(conf_size*1024*1024) { + if sum > int(conf_size*1024) { return fmt.Errorf("Repository larger than %f M. Please clean up or contact the teaching team.", conf_size) } return nil -- 2.30.2 From dd40a17476ede19c88187224e41d8eb3937af581 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Sat, 12 Oct 2024 17:59:26 +0800 Subject: [PATCH 5/7] fix(healthcheck/reposize): output format --- pkg/healthcheck/reposize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index ee61bba..58820eb 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -34,7 +34,7 @@ func RepoSize(conf_size float64) error { } } if sum > int(conf_size*1024) { - return fmt.Errorf("Repository larger than %f M. Please clean up or contact the teaching team.", conf_size) + return fmt.Errorf("Repository larger than %.1f Mib. Please clean up or contact the teaching team.", conf_size) } return nil } -- 2.30.2 From aa2969a82f8c7dd6c42f2360fc220246437b5290 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Sat, 12 Oct 2024 18:01:20 +0800 Subject: [PATCH 6/7] fix(healthcheck/reposize): camel name style --- pkg/healthcheck/reposize.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index 58820eb..bb69670 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -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(conf_size float64) error { +func RepoSize(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("git", "count-objects", "-v") @@ -33,8 +33,8 @@ func RepoSize(conf_size float64) error { sum += size } } - if sum > int(conf_size*1024) { - return fmt.Errorf("Repository larger than %.1f Mib. Please clean up or contact the teaching team.", conf_size) + if sum > int(confSize*1024) { + return fmt.Errorf("Repository larger than %.1f Mib. Please clean up or contact the teaching team.", confSize) } return nil } -- 2.30.2 From acc0ccf88ca911072f90569766ac3a8e969aeb30 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sat, 12 Oct 2024 06:26:46 -0400 Subject: [PATCH 7/7] fix: typo --- pkg/healthcheck/reposize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index bb69670..939adb8 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -34,7 +34,7 @@ func RepoSize(confSize float64) error { } } if sum > int(confSize*1024) { - return fmt.Errorf("Repository larger than %.1f Mib. Please clean up or contact the teaching team.", confSize) + return fmt.Errorf("Repository larger than %.1f MiB. Please clean up or contact the teaching team.", confSize) } return nil } -- 2.30.2