feat: repo health check (#16) #17

Merged
张泊明518370910136 merged 37 commits from file_check into master 2024-09-11 20:09:27 +08:00
3 changed files with 7 additions and 7 deletions
Showing only changes of commit 2838f4171f - Show all commits

View File

@ -73,7 +73,7 @@ func main() {
fmt.Printf("## Non-ASCII Characters Commit Message Check Failed:\n%s\n", err.Error())
}
// TODO: find a way to test the release tag
bomingzh marked this conversation as resolved Outdated

check releases need to use Gitea API, just check tags is enough

check releases need to use Gitea API, just check tags is enough

Yep, only check tags

Yep, only check tags

Where is it tested?

Where is it tested?
err = healthcheck.CheckReleases(*rootDir, *releaseCategories, *releaseNumber)
err = healthcheck.CheckTags(*rootDir, *releaseCategories, *releaseNumber)
if err != nil {
fmt.Printf("## Release Tag Check Failed:\n%s\n", err.Error())
}

View File

@ -54,13 +54,14 @@ func getForbiddens(root string, fileList []string, localList string) ([]string,
}
if info.IsDir() {
if info.Name() == ".git" || info.Name() == ".gitea" || info.Name() == "ci" {
switch {
case info.Name() == ".git" || info.Name() == ".gitea" || info.Name() == "ci":
return filepath.SkipDir
} else if localList != "" {
case localList != "":
if inString(info.Name(), dirs) {
return filepath.SkipDir
}
} else {
default:
return nil
}
}

View File

@ -2,7 +2,6 @@ package healthcheck
import (
"fmt"
"strings"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
@ -31,7 +30,7 @@ func getTagsFromRepo(repoPath string) ([]string, error) {
return tags, nil
}
func CheckReleases(repoPath string, category string, n int) error {
func CheckTags(repoPath string, category string, n int) error {
tags, err := getTagsFromRepo(repoPath)
if err != nil {
return fmt.Errorf("error getting tags: %v", err)
@ -56,7 +55,7 @@ func CheckReleases(repoPath string, category string, n int) error {
}
}
if !found {
return fmt.Errorf("Wrong release tag '%s' or missing release tags. Please use one of '%s'.", target, strings.Join(tags, "', '"))
return fmt.Errorf("Expected tag '%s' not found.", target)
}
return nil
}