Skip to content

Commit

Permalink
Merge pull request #36 from Adirio/descriptiveness-check-overhaul
Browse files Browse the repository at this point in the history
✨ Descriptiveness check overhaul
  • Loading branch information
k8s-ci-robot committed Feb 2, 2021
2 parents 7259830 + 3d74348 commit 01981b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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()
}

0 comments on commit 01981b8

Please sign in to comment.