Skip to content

Commit

Permalink
Measure descriptiveness by characters (80) instead of lines (2)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
  • Loading branch information
Adirio committed Feb 2, 2021
1 parent 7259830 commit ee3a5c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions verify/descriptiveness.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package main

import (
"strings"

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

"sigs.k8s.io/kubebuilder-release-tools/verify/pkg/action"
Expand All @@ -36,16 +34,9 @@ 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
}
lineCnt++
}
if lineCnt < requiredLines {
if len(pr.GetBody()) < requiredCharacters {
return "", "", &prDescriptivenessError{}
}
return "Your PR looks descriptive enough!", "", nil
Expand Down
2 changes: 1 addition & 1 deletion verify/main.go
Original file line number Diff line number Diff line change
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 ee3a5c2

Please sign in to comment.