chore: finish initial version of validation script
This commit is contained in:
parent
9e48eb806f
commit
3b9ec5ec41
@ -359,6 +359,25 @@ func validateContributorYaml(yml contributorFrontmatterWithFilePath) []error {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportedFileFormats := []string{".png", ".jpeg", ".jpg", ".gif", ".svg"}
|
||||||
|
matched := false
|
||||||
|
for _, ff := range supportedFileFormats {
|
||||||
|
matched = strings.HasSuffix(*yml.AvatarUrl, ff)
|
||||||
|
if matched {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !matched {
|
||||||
|
problems = append(
|
||||||
|
problems,
|
||||||
|
fmt.Errorf(
|
||||||
|
"avatar URL for %q does not end in a supported file format: [%s]",
|
||||||
|
yml.FilePath,
|
||||||
|
strings.Join(supportedFileFormats, ", "),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return problems
|
return problems
|
||||||
@ -515,7 +534,19 @@ func validateRelativeUrls(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(con.GithubUsername, con.FilePath, con.AvatarUrl)
|
absolutePath := strings.TrimSuffix(con.FilePath, "README.md") +
|
||||||
|
*con.AvatarUrl
|
||||||
|
_, err := os.ReadFile(absolutePath)
|
||||||
|
if err != nil {
|
||||||
|
problems = append(
|
||||||
|
problems,
|
||||||
|
fmt.Errorf(
|
||||||
|
"relative avatar path %q for %q does not point to image in file system",
|
||||||
|
*con.AvatarUrl,
|
||||||
|
con.FilePath,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(problems) == 0 {
|
if len(problems) == 0 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user