feat(healthcheck/releasetag): recommended tag listcheck
This commit is contained in:
parent
b46e22471f
commit
1e0cbb48f0
|
@ -61,19 +61,8 @@ func getTagsFromRepo(repoPath string) ([]string, error) {
|
||||||
return tags, nil
|
return tags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckTags(repoPath string, skip bool) error {
|
// INFO: check whether release tag consistent with last commit msg scope
|
||||||
if skip {
|
func checkConsist(tags []string, target string) (err error) {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
tags, err := getTagsFromRepo(repoPath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error getting tags from repo: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
target, err := getTagFromMsg()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error getting tag from msg scope: %v", err)
|
|
||||||
}
|
|
||||||
found := false
|
found := false
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
if tag == target {
|
if tag == target {
|
||||||
|
@ -86,3 +75,54 @@ func CheckTags(repoPath string, skip bool) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INFO: check whether release tag follow the tag list we give
|
||||||
|
func checkStyle(tags []string, category string, n int) (err error) {
|
||||||
|
var prefix string
|
||||||
|
switch category {
|
||||||
|
case "exam":
|
||||||
|
prefix = "e"
|
||||||
|
case "project":
|
||||||
|
prefix = "p"
|
||||||
|
case "homework":
|
||||||
|
prefix = "h"
|
||||||
|
default:
|
||||||
|
prefix = "a"
|
||||||
|
}
|
||||||
|
target := prefix + fmt.Sprintf("%d", n)
|
||||||
|
found := false
|
||||||
|
for _, tag := range tags {
|
||||||
|
if tag == target {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return fmt.Errorf("Wrong release tag '%s' or missing release tags. Please use one of '%s'.", strings.Join(tags, "', '"), target)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckTags(repoPath string, skip bool, category string, n int) error {
|
||||||
|
if skip {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
tags, err := getTagsFromRepo(repoPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting tags from repo: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
target, err := getTagFromMsg()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error getting tag from msg scope: %v", err)
|
||||||
|
}
|
||||||
|
err = checkConsist(tags, target)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = checkStyle(tags, category, n)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user