Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Descriptiveness check overhaul #36

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions verify/descriptiveness.go
Expand Up @@ -24,6 +24,8 @@ import (
"sigs.k8s.io/kubebuilder-release-tools/verify/pkg/action"
)

const skipDescriptivenessCheckLabel = "skip-descriptiveness-check"

type prDescriptivenessError struct{}

func (e prDescriptivenessError) Error() string {
Expand All @@ -36,16 +38,15 @@ Someone reading the PR description without clicking any issue links should be ab
}

// checkPRDescriptiveness
func checkPRDescriptiveness(requiredLines int) action.ValidateFunc {
func checkPRDescriptiveness(requiredCharacters int) action.ValidateFunc {
return func(pr *github.PullRequest) (string, string, error) {
lineCnt := 0
for _, line := range strings.Split(pr.GetBody(), "\n") {
if strings.TrimSpace(line) == "" {
continue
for _, label := range pr.Labels {
if label.Name != nil && *label.Name == skipDescriptivenessCheckLabel {
return "Skipping descriptiveness check!", "", nil
}
lineCnt++
}
if lineCnt < requiredLines {

if len(strings.TrimSpace(pr.GetBody())) < requiredCharacters {
return "", "", &prDescriptivenessError{}
}
return "Your PR looks descriptive enough!", "", nil
Expand Down
2 changes: 1 addition & 1 deletion verify/main.go
Expand Up @@ -35,7 +35,7 @@ func main() {
action.NewPlugin(
"PR Desc",
"Basic PR Descriptiveness Check",
checkPRDescriptiveness(2),
checkPRDescriptiveness(80),
),
).Run()
}