Skip to content

Commit

Permalink
Skip descriptiveness check if the "skip-descriptiveness-check" flag i…
Browse files Browse the repository at this point in the history
…s set.

Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
  • Loading branch information
Adirio committed Feb 2, 2021
1 parent ee3a5c2 commit 3d74348
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion verify/descriptiveness.go
Expand Up @@ -17,11 +17,15 @@ limitations under the License.
package main

import (
"strings"

"github.com/google/go-github/v32/github"

"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,7 +40,13 @@ Someone reading the PR description without clicking any issue links should be ab
// checkPRDescriptiveness
func checkPRDescriptiveness(requiredCharacters int) action.ValidateFunc {
return func(pr *github.PullRequest) (string, string, error) {
if len(pr.GetBody()) < requiredCharacters {
for _, label := range pr.Labels {
if label.Name != nil && *label.Name == skipDescriptivenessCheckLabel {
return "Skipping descriptiveness check!", "", nil
}
}

if len(strings.TrimSpace(pr.GetBody())) < requiredCharacters {
return "", "", &prDescriptivenessError{}
}
return "Your PR looks descriptive enough!", "", nil
Expand Down

0 comments on commit 3d74348

Please sign in to comment.